[PD] [expr $f1 if...] bug?

Mathieu Bouchard matju at artengine.ca
Tue Jan 31 19:04:04 CET 2012


Le 2012-01-31 à 18:33:00, Lorenzo Sutton a écrit :
> On 31/01/2012 16:07, Jonghyun Kim wrote:
>> expr $f1;
>> if ($f1 == 1, 1, 0);
>> if ($f1 == 5, 2, 0);
>> if ($f1 == 9, 3, 0);
>> if ($f1 == 13, 4, 0);
>> if ($f1 == 17, 5, 0);
>> if ($f1 == 21, 6, 0);
>> if ($f1 == 25, 7, 0);
>> if ($f1 == 29, 8, 0);
>> if ($f1 == 33, 9, 0);
>> if ($f1 == 37, 10, 0);
>> if ($f1 == 41, 11, 0);
>> if ($f1 == 45, 12, 0);
> You could also use a [select] instead of [expr]. Something like
> |
> [sel 1 5 9  ...    ]
> |   |   |   ...   |
> [1( [2( [3( ...  [t b]
>                  |
>                  [0(

Now that I think of it, with GridFlow (any version), you have this :

[listfind 1 5 9 13 17 21 25 29 33 37 41 45]
  |
[+ 1]

To get a single index from 1 to 12, or 0 if not found.

If you really need to send a zero for each time something is not found, 
however, you can do this :

[#outer == (1 5 9 13 17 21 25 29 33 37 41 45)]
  |
[# * (1 2 3 4 5 6 7 8 9 10 11 12)]
  |
[#unpack 12]
||||||||||||

But because of the pattern of numbers involved (equally spaced), you could 
use [mod 4] and [div 4] to separate $f1 into two parts, one part that 
should be 1, and the other that should be between 1 and 12. That's quite a 
shortcut.

  ______________________________________________________________________
| Mathieu BOUCHARD ----- téléphone : +1.514.383.3801 ----- Montréal, QC


More information about the Pd-list mailing list