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
