User:Oleg Kobchenko/Explicit Definitions
Jump to navigation
Jump to search
Common Uses
Default x
One-liner
v=: 4 : 'x+y' v 4 : 'x+y' (1&$:) : v 1&$: :v (1&$:) : v f. 1&$: :(4 : 'x+y')
Multi-liner
w=: 4 : 0 a=. y x+a ) (1&$:) : w f. 1&$: :(4 : 0) a=. y x+a )
Attaching Rank
Separate and common monad/dyad ranks
((1&$:)"1) : (w"0) f. NB. both ranks 1&$:"1 :(4 : 0"0) a=. y x+a )
Common rank and separate rank
w1=: (1&$:) : w"0 f. w1 1&$: :(4 : 0)"0 a=. y x+a ) w2=: (1&$:) : (w"0) f. w2 1&$: :(4 : 0"0) a=. y x+a ) w1 b.0 0 0 0 w2 b.0 _ 0 0
Attaching Other Conjunctions
Explicit conjunction provides just an ordinary J expression, which can be combined with other conjunctions and trains
Attaching each
u=. 3 : 'y+1'&.> u i.3 +-+-+-+ |1|2|3| +-+-+-+
Uncommon Uses
Double Explicit
z2=: 3 : 0"0 : (4 : 0"0) a=.y x+y ) a=.y y+1 ) z2 3 : 0"0 :(4 : 0"0) a=.y x+y ) a=.y y+1 )
Order of "declaration" should be monad : dyad, while the order of bodies is dyad ) monad ), because the declaration line is executed from right to left. Thanks to June Kim for clarification.
Simultaneous Assignment
Compound declaration can be used in many cases, such as simultaneous assignment
Simultaneous Assignment
Compound declaration can be used in many cases, such as simultaneous assignment
'`a b c'=: (4 :0)`(4 :0)`(4 :0) x+y ) x-y ) x*y ) a 4 : 'x*y' b 4 : 'x-y' c 4 : 'x+y'