reversing [toggle] output

flim's icon

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

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

broc's icon
Max Patch
Copy patch and select New From Clipboard in Max.
flim's icon

that I like.

thanks!

Roman Thilenius's icon

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

or just [== 0].

or why not [!= 1]?

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

flim's icon

:)

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

ch's icon

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

Luke Hall's icon

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

brendan mccloskey's icon

laugh my f ass right OFF

Luke Hall's icon

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

brendan mccloskey's icon

transcendental.......

Rodrigo's icon

I'm all about the [!- 1]

flim's icon

@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...

broc's icon

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

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

christripledot's icon

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