> On Wed, Jan 2, 2013 at 10:04 AM, Raul Miller <[email protected]>
> wrote:
> > Here's a definition for at which works exactly like @
> >
> >    at=: 2 :'([: u v)"v

   at=: 2 :'([: u v)"v'
   3 4 5 < at #"0 i.3
+-----+-------+---------+
|0 0 0|1 1 1 1|2 2 2 2 2|
+-----+-------+---------+

Linda - we've done it! We've got rid of @!

But we used a conjunction to do it, so the same reasoning applies; we
avoided making J massage an intermediate result into something rectangular.

> Date: Thu, 3 Jan 2013 14:53:17 -0800
> From: Nollaig MacKenzie <[email protected]>
> To: [email protected]
> Subject: Re: [Jprogramming] Atop continues to puzzle me
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=us-ascii
> 
> ...
> 
> 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

Linda, I think this 'general argument about J functions having to produce
rectangular arrays' should help you see why there are benefits in embracing
@ and the other conjunctions as your friends, to be used as convenient.

Now in your first examples below, rectangular intermediate results are
inevitable anyway, so @ is not necessary.

I found function composition unnatural. I'm getting used to it and enjoying
mixing implicit and explicit as I am inclined. Sometimes, though, I have
little choice, especially with boxed ragged arrays.

> Date: Fri, 04 Jan 2013 06:18:01 -0500
> From: "Linda Alvord" <[email protected]>
> To: <[email protected]>
> Subject: Re: [Jprogramming] Atop continues to puzzle me
> Message-ID: <002f01cdea6d$2936bb40$7ba431c0$@net>
> Content-Type: text/plain; charset=ks_c_5601-1987
> 
> Here's my progress so far:
> 
>    2 |.@(*"1) a=:i.2 3
>  4 2 0
> 10 8 6
>    (|."1) 2(*"1)a
>  4 2 0
> 10 8 6
>    2 |.@:(*"1) a
> 6 8 10
> 0 2  4
>    |. 2*"1 a
> 6 8 10
> 0 2  4
>    3 4 5<@#"0 i.3
> +-----+-------+---------+
> |0 0 0|1 1 1 1|2 2 2 2 2|
> +-----+-------+---------+
>    3 4 5#"0&.> i.3
> +-----+-------+---------+
> |0 0 0|1 1 1 1|2 2 2 2 2|
> +-----+-------+---------+
> 
> I am trying to remove &. following these rules:
> 
>    NB. x u&v y ? (v x) u (v y)
>    NB. u &.v is equivalent to the composition u & v
>    NB. except that the verb obverse to v is applied
>    NB. to the result for each cell
>    NB.(subject to the monadic rank of v)
> 
>    (<"1 3 4 5 )   #"0      (>"0  i.3)
> |length error
> |   (    <"1 3 4 5)#"0(>"0 i.3)
> 
>  The is one of my better tries to follow the directions.
> 
> Linda

Regards

Graham

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to