• ### Perform operations on list without \[unpack\]

So I,ve got a simple list comprised of three values, ID X and Y (all floats). I'm comparing distance between many ID's to one ID using [expr] but it requires unpacking all of the lists and it becomes just gigantic (tons of inlets and outlets on [expr]. What i'd like to do is access each inlet and it's list components using dot or array syntax like so:

\$f1[1] + \$f5[2] or \$f1.1 + \$f5.2

so in the above, add the 2nd item of the first inlet with the third item of the 5th inlet (remembering 0 is the first item in the list). BTW, I know this isn't a distance formula.

Any ideas?

Hdez

• Posts 7 | Views 4946
• In PD, sending a list to the first inlet is like sending the individual atoms of the list to each inlet in order.

Hope this helps.

http://www.pdpatchrepo.info/hurleur/listexample.pd

• thanks, that actually helped in a different way. a follow up: is there a way to square or use other exponents in [expr]? I'm basically trying to code Euclidean distance formula in one [expr] without having to use [pow 2] and [sqrt] (the latter of which I know I can use in the formula as sqrt(x)). What I think all of this should look like:

[expr sqrt(pow2(abs(\$f1 - \$f3) + abs(\$f2 - \$f4)))]

Getting hung up on "pow2" part

It just occurred to me that maybe there is already an external that does this and I don't know about it.

thanks,

hdez

http://www.pdpatchrepo.info/hurleur/euclidean-distance.pd

• Eureka! I found it:
[expr sqrt(pow(abs(\$f1 - \$f3), 2) + pow(abs(\$f2 - \$f4), 2))]

pow(x,y) where x = the number to be squared and y = exponent;

hdez

• I know this isn't the right place, but I'll post it as a follow up. Here is an abstraction called e-distance which uses the Euclidian distance between two points. The four inlets from left to right are X1 Y1 X2 Y2.

http://www.pdpatchrepo.info/hurleur/e-distance.pd

• thanks for posting the solution... proper nettiquete

Dual 1.8 IBM G5: Mac OSX 10.4.11 -- Asus eeePC 701: Pure:Dyne / eeeXubuntu GNU/Linux -- myspace.com/thearifd

• @hdez said:

What i'd like to do is access each inlet and it's list components using dot or array syntax like so:

\$f1[1] + \$f5[2] or \$f1.1 + \$f5.2

You can actually access arrays in [expr]:

[0\ <--index
|
[expr arrayname[\$f1]]

Or, you could substitute "arrayname" with "\$s2" (symbol variable) and dynamically change arrays.

Posts 7 | Views 4946
Internal error.

Oops! Looks like something went wrong!