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

Reply via email to