Of course, you can also use juxtaposition and J's parser to achieve function composition:
compose=: 2 :0 u v y : (v x) u v y ) comp=: 2 :0 u compose v " v ) f=. (# L: 0) comp <"0 3 4 5 f i. 3 +-----+-------+---------+ |0 0 0|1 1 1 1|2 2 2 2 2| +-----+-------+---------+ FYI, -- Raul On Thu, Jan 3, 2013 at 5:53 PM, Nollaig MacKenzie <[email protected]> wrote: > > On 2013.01.03 08:25:58, you, > the extraordinary Graham Parkhouse, spake thus: > >> Subject: Re: Atop continues to puzzle me >> >> >> This post was initially titled 'The benefits of function composition' >> > ... > >> There are things you can achieve with function composition that cannot be >> achieved so elegantly any other way: >> >> 3 4 5<@#"0 i.3 >> +-----+-------+---------+ >> |0 0 0|1 1 1 1|2 2 2 2 2| >> +-----+-------+---------+ >> >> This is what I want - a set of 3 0s, a set of 4 1s and a set of 5 2s. >> >> This doesn't give me what I want: >> >> 3 4 5#"0 i.3 > ... >> >> Nor does this: >> >> 3 4 5 ([: <"1 #"0) i.3 > ... > >> But this does: >> >> each >> +--+-+ >> |&.|>| >> +--+-+ >> 3 4 5#"0 each i.3 > >> ... but then &. is function composition. > > I thought there might be a way of getting a function > without using composition by using "L:" . But the > best I came up with was: > > f=. (# L: 0) & <"0 > 3 4 5 f i.3 > > +-----+-------+---------+ > |0 0 0|1 1 1 1|2 2 2 2 2| > +-----+-------+---------+ > > But the "&" vitiates the attempt. > > The general argument about J functions having > to produce rectangular arrays should have > convinced me anyway. > > NM > > -- > Nollaig MacKenzie > http://www.yorku.ca/nollaig > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
