Absolute Value Of List Values

kpmusic's icon

Hi all,
What might be the best way to take a given list (say 100 float values with some negative numbers and some positive) and perform an absolute value operation of all the numbers (and prepend the result into another list.) Basically, I need to format a list that has negative values into a new list with the same values, except the negative floats are now positive.
I guess i could unpack all floats, repack them once i've used |abs 0.| but that seems a little intense for lists that could be very long.

Thanks for the help!
-kp

gusanomaxlist's icon

hi.
try with [vexpr abs($f1)].
best.

Emmanuel Jourdan's icon

On 14 nov. 07, at 19:44, kevin pooler wrote:

> Hi all,
> What might be the best way to take a given list (say 100 float
> values with some negative numbers and some positive) and perform an
> absolute value operation of all the numbers (and prepend the result
> into another list.) Basically, I need to format a list that has
> negative values into a new list with the same values, except the
> negative floats are now positive.
> I guess i could unpack all floats, repack them once i've
> used |abs 0.| but that seems a little intense for lists
> that could be very long.

You can do that with vexpr.

ej

Max Patch
Copy patch and select New From Clipboard in Max.

Jennek Geels's icon

On 14-nov-2007, at 19:44, kevin pooler wrote:

>
> Hi all,
> What might be the best way to take a given list (say 100 float
> values with some negative numbers and some positive) and perform an
> absolute value operation of all the numbers (and prepend the result
> into another list.) Basically, I need to format a list that has
> negative values into a new list with the same values, except the
> negative floats are now positive.
> I guess i could unpack all floats, repack them once i've
> used |abs 0.| but that seems a little intense for lists
> that could be very long.
>
> Thanks for the help!
> -kp

Labs from Lobjects by Peter Elsea
see www.maxobjects.com for details
HtH
-jennek