[Jprogramming] Request for code critique '&. Hello'

John Randall randall at andromeda.rutgers.edu
Sat Feb 11 04:31:30 HKT 2006


Oleg Kobchenko wrote:
> To get short circuit conditions, here is the pattern:
>
> vDef ` vN at .cN ` vN_1 at .cN_1 ` ... ` v2 at .c2 ` v1 at .c1 arg
>

Thanks, Oleg!  This is exactly what I was looking for.  I guess I have to
learn more about the order of operations.

Here is a very simple example using your construction that clearly
demonstrates the short-circuit.



a1=:3 : 0
smoutput 'a1'
y.+1
)
a2=:3 : 0
smoutput 'a2'
y.+2
)
def=:3 : 0
smoutput 'default'
y.
)
c1=:3 : 0
smoutput 'c1'
y.>0
)
c2=:3 : 0
smoutput 'c2'
y.<0
)

v=:def`a2 at .c2`a1 at .c1

   v 1
c1
a1
2
   v _1
c1
c2
a2
1
   v 0
c1
c2
default
0


Best wishes,

John




More information about the Programming mailing list