Forums > Max For Live

### One list comparision with several lists

Mar 19 2014 | 6:17 am

Hi.
A little bit stuck with lists.

I want to do something like this:

If [list_0] equal [list_1]
Then (set 1)
Else
If [list_0] equal [list_2]
Then (set 2)
Else If [list_0] equal [list_3]
Then (set 3)
Else (set 4)

Mar 19 2014 | 11:53 am

Here’s a simple solution which should give you an idea…

```<code>
-- Pasted Max  Patch, click to expand. --

</code>
```
Mar 19 2014 | 12:16 pm

Another one, bit more easy to expand and configure

```<code>
-- Pasted Max  Patch, click to expand. --

</code>
```
Mar 20 2014 | 5:40 am

Hi,

this is just a variation on Lee’s work using uzi.

I think it’s nice to use zero as the output if there is no match.

Richard

```<code>
-- Pasted Max  Patch, click to expand. --

</code>
```
Mar 20 2014 | 7:54 am

i would use expr (as we know)

[zl compare] [zl compare] [zl compare] [zl compare]
[expr (\$i1=1) + (\$i2=1)*2 + (\$i3=1)*3 + (\$i4=1)*4]

this, as well as the solutions by the others, wont work when more than one condition is true.

-110

Mar 20 2014 | 1:53 pm

Thanks all.
I think the best solution for me is to use 4 [zl.compare] with [expr].
But it’s all not so good… None of the algorythms is working with my setup, because of some bug, or i don’t know.
[zl.compare] somehow is not comparing complex lists even if they are equal.
But with simple lists everything is ok.
Here is example.

```<code>
-- Pasted Max  Patch, click to expand. --

</code>
```
Mar 20 2014 | 4:07 pm

it looks like it’s got something to do with rounding error in floating point representation in max.
here’s a version which ‘works’, if the magnitudes are rounded to the nearest 1/64 (-36db error)

```<code>
-- Pasted Max  Patch, click to expand. --

</code>
```
Mar 21 2014 | 5:08 am

Thanks, for help. I thought about that this problem is with lists in message boxes which are already rounded.

Mar 21 2014 | 6:57 am

And if you’re just interesting in finding the closest list, you can use zsa.dist:

```<code>
-- Pasted Max  Patch, click to expand. --

</code>
```
Mar 21 2014 | 3:44 pm

Sorry, Emmanuel, but my max4live version is not supporting this library even in 32bit compatibility mode.

Mar 21 2014 | 5:53 pm

use this expression to truncate the rounding error to 6 decimal places
vexpr int(\$f1 * 1000000.)/1000000.

this will give you a -140db error

```<code>
-- Pasted Max  Patch, click to expand. --

</code>
```
Mar 22 2014 | 4:32 am

Hi

— Pasted Max Patch, click to expand. —
Mar 22 2014 | 1:08 pm

@ivnos it should work both in 32 or 64 bits. At least that’s what I’m seeing here using the latest versions of Max, Live and zsa.descriptors. Feel free to contact me if you’re still experiencing some problems.

Mar 23 2014 | 5:47 am

Floating Point, thanks again, but your previous variant were enough. =)

eltopo, sorry but i don’t understand your patch.

Emmanuel, sorry, forgot to install it properly (forgot to copy it into packages).

Viewing 14 posts - 1 through 14 (of 14 total)

Forums > Max For Live