Here's an implementation of your if/then/else variant: else=: 2 :0 |. u`v )
then=: 2 :0 n@.u"((1{n)`:6) ) if=: ] a =: assert a 4 1 0 2 4 -: if (<0:) then (*: else +:) i:2 a 4 1 0 2 4 -: (if (<0:) then (*: else +:)) i:2 a (if ] then (| else -.)) 1 1 0 0 1 0 1 0 a if ] then (| else -.) 1 1 0 0 1 0 1 0 Let me know if you want any explanation of either this variant or of the variant at http://jsoftware.com/pipermail/programming/2014-February/034884.html - questions can help. Thanks, -- Raul On Tue, Feb 4, 2014 at 3:48 AM, Michal Wallace <michal.wall...@gmail.com> wrote: > ('O' if (=0:) else ('<' if (<0:) else '>'))"0 i:5 > <<<<<O>>>>> > > There are nicer ways to make this output, > but how would you code 'if' and 'else' above? > > Or... 'if'/'then'/'else' below, if you prefer? > > a =: assert > a 4 1 0 2 4 -: if (<0:) then (*: else +:) i:2 > a 4 1 0 2 4 -: (if (<0:) then (*: else +:)) i:2 > a (if ] then (| else -.)) 1 1 0 0 1 0 1 0 > a if ] then (| else -.) 1 1 0 0 1 0 1 0 > > My versions are here: > > https://github.com/tangentstorm/tangentlabs/blob/master/j/syntax.ijs > > Thoughts? :) > > -Michal > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm