Forums > MaxMSP

reversing [toggle] output

November 7, 2011 | 7:04 pm

hello!

is there a more elegant way to reverse my [toggle] output? my attempt does the job using [if $i1 > 0 then 0 else 1]. so, what else is there? :)

cheers,

jonas

– Pasted Max Patch, click to expand. –

November 7, 2011 | 7:11 pm
– Pasted Max Patch, click to expand. –

November 7, 2011 | 7:14 pm

that I like.

thanks!


November 7, 2011 | 8:06 pm

shorter: [if $i1 then 1 else 0].

or just [== 0].

or why not [!= 1]?

[expr ($f1+1)%1] should also work. :)


November 7, 2011 | 8:16 pm

:)

do like the equal/not equal alternative. and thanks for pointing out that my [if] can be further reduced…



Ch
November 7, 2011 | 10:44 pm

I agree [== 0] is the way to go. the most readable one.
Two others ways, just for fun : [expr $i1^1] [expr !$i1]


November 7, 2011 | 11:31 pm

The old classic [expr int($i1*pow(2,3)/ln(9)*-1/3+1)] is the best! ;)


November 7, 2011 | 11:59 pm

laugh my f ass right OFF


November 8, 2011 | 12:08 am

Only because getting Euler’s identity into the [expr] object looked like a bit of a challenge!


November 8, 2011 | 12:32 am

transcendental…….


November 8, 2011 | 12:53 am

I’m all about the [!- 1]


November 8, 2011 | 8:44 am

@Roman
you meant [if $i1 then 0 else 1]

[!- 1], yeah :) can’t get any slimmer.

also thanks for the insight into [expr]. endless potential, the fella…


November 8, 2011 | 11:18 am

[!- 1] or [== 0] ?

I think it just depends whether you consider 0 1 as numbers or booleans.


November 8, 2011 | 7:39 pm

[!- 1] is branchless. Wins every time.


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