Look at the definition of dyadic Bond. You could also do it like this 1-~i.6 _1 0 1 2 3 4
2 |^:(0<])"0 i:3 _3 _2 _1 0 1 0 1 See http://www.jsoftware.com/jwiki/Essays/Short_Circuit_Boolean ----- Original Message ---- From: David Wallin <[EMAIL PROTECTED]> To: [email protected] Sent: Tuesday, June 20, 2006 1:58:21 PM Subject: [Jprogramming] agenda/bond conjunction confusion Hi, I'm pretty new to J and I'm still struggling a bit with the syntax. I was trying to write a small 'mod' function that left negative numbers untouched. The result I expected is that of 'mod3', 'mod6' and 'mod7' below. If someone could give me some insights as to why the results differ I'd appreciate it. mod2=: ((|`] @. (<&0)))"0 mod3=: ((]`| @. (>&0)))"0 mod4=: ((|`] @. (<&1)))"0 mod5=: ((]`| @. (>&1)))"0 mod6=: ((|`] @. (]<0:)))"0 mod7=: ((|`] @. (]<1:)))"0 4 mod2 1-~i.6 3 0 1 2 3 0 4 mod3 1-~i.6 _1 0 1 2 3 0 4 mod4 1-~i.6 3 0 1 2 3 4 4 mod5 1-~i.6 _1 0 1 2 3 4 4 mod6 1-~i.6 _1 0 1 2 3 0 4 mod7 1-~i.6 _1 0 1 2 3 0 BTW, is there an IRC channel for J ? cheers, --david. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
