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-04-02
last updated: 2004-10-21


The dyad # now supports sparse arguments. For example:

   ] d=: (?. 5$2) * ?. 5 4$20
0 0  0  0
4 0 13 13
0 0  0  0
0 1 10 13
0 0  0  0

   ] s=: (2;0) $. d
1 | 4 0 13 13
3 | 0 1 10 13

   1 2 3 0 1 # d
0 0  0  0
4 0 13 13
4 0 13 13
0 0  0  0
0 0  0  0
0 0  0  0
0 0  0  0

   1 2 3 0 1 # s
1 | 4 0 13 13
2 | 4 0 13 13

   (1 2 3 0 1 # d) -: 1 2 3 0 1 # s
1

   i=: ?. 1e3 $ 1e9
   x=: ?. 1e3 $ 1e6
   v=: x i} 1 $. 1e9 ; 0 ; 2-2

   $ v
1000000000
   $ (0.99e6 >: v) # v
999999994
   $ (0.99e6 <  v) # v
6

   (0.99e6 < v) # v
0 | 991037
1 | 991533
2 | 995400
3 | 997598
4 | 999116
5 | 999457



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