Help / Release / J 4.06 / { Sparse Arguments

From J Wiki
Jump to navigation Jump to search


>> << Pri JfC LJ Phr Dic Voc !: Rel NuVoc wd Help Release



{

Sparse Arguments

initial writing: 2001-03-01
last updated: 2004-10-26


The dyads { now supports sparse left arguments. (It had long supported sparse right arguments.) For example:

   ] d=: ?. 2 3 $ 7
0 5 3
3 1 0

   ] s=: $. d
0 1 | 5
0 2 | 3
1 0 | 3
1 1 | 1

   ] v=: 7 ?. 7
6 1 2 5 4 3 0

   s{v
0 1 | 3
0 2 | 5
1 0 | 5
1 1 | 1

   $.^:_1 s{v
6 3 5
5 1 6

   d{v
6 3 5
5 1 6

   (s{v) -: d{v
1

   s{i.7 3
|non-unique sparse elements
|   s    {i.7 3

   s{"(1) 0,. 10 20+/i.7
0 1 | 14
0 2 | 12
1 0 | 22
1 1 | 20

   d{"(1) 0,. 10 20+/i.7
 0 14 12
22 20  0

   s{"(1) 10 20+/i.7
|non-unique sparse elements
|   s    {"(1)10 20+/i.7

   j=: ?. 1000$2e9
   s=: 1 j} 1 $. 2e9 ;0;0
   $s
2000000000
   $ s { 10 20
2000000000
   (s { 10 20) -: 20 j} 1 $. 2e9;0;10
1



>> << Pri JfC LJ Phr Dic Voc !: Rel NuVoc wd Help Release