I can't help you with what this means, but this gives the same result.
f=: 13 :'$i.$i.y'
f
[: ($ i.) [: $ i.
But here is the surprise.
g=: 13 :'($i.)$.y'
g
g
[: ($ i.) $.
My typing error produces the same result
g 2 3
0 1 2
3 4 5
0 1 2
3 4 5
0 1 2
3 4 5
Note the function $. Or sparse instead of $ shape:
$. 2 3
0 │ 2
1 │ 3
$. 2 3
0 │ 2
1 │ 3
(f 2 3)-:g 2 3
1
I've never come across sparse before and I haven't figured out how it
works yet.
Linda
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Raul Miller
Sent: Monday, October 31, 2011 7:50 AM
To: Programming forum
Subject: Re: [Jprogramming] Newbie question about repetition...
I am trying to figure out what ($~$) means -- when would it ever be useful?
Intuitively, it is an identity function for arrays with 0 or 1
dimension. For matrices, it gives a different result:
($~$) i. 2 3
0 1 2
3 4 5
0 1 2
3 4 5
0 1 2
3 4 5
For higher dimensional arrays it gets even more complicated.
So.... if you do not mind me asking: what are you using this for?
Thanks,
--
Raul
On Mon, Oct 31, 2011 at 5:19 AM, Linda Alvord <[email protected]>
wrote:
> As I've been getting caught up with J, I've found it is often useful to
keep
> going a little longer and sometimes you notice things you might not
> otherwise see.
>
> r =: 1 2 3 4
> v =: 13 14 15 16
>
> Actually r and v change places so:
>
> f=: 13 :'x # ($~ $) y'
> f
> [ # [: ($~ $) ]
>
> +/v f r
> 150
>
> Linda
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Dan T. Abell
> Sent: Thursday, March 10, 2011 10:08 AM
> To: Programming forum
> Subject: Re: [Jprogramming] Newbie question about repetition...
>
>
> On 10 Mar 2011, at 07:35, Raul Miller wrote:
>
>> On Thu, Mar 10, 2011 at 8:29 AM, Henry Rich <[email protected]> wrote:
>>> repeats # values
>>
>> That is how I would approach this problem.
>
> and for part two of the question:
> r # ($r)$v
>
>
>> --
>> Raul
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>
> --
> Dan T. Abell :: dabell at txcorp dot com :: 303.444.2452
> Tech-X Corp., 5621 Arapahoe Ave, Ste A, Boulder CO 80303
> http://www.txcorp.com :: 303.748.6894/c 303.448.7756/fx
>
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm