spreadsheets have a range selection syntax like A1:C3&F4~B2  which means the 
block range from A1 to C3 with the cell F4 added, and the cell B2 removed.

Ignoring the letter conversions, here are some useful J functions for building 
a list of selectors (can be used with both { and }).  Conjunctions are used for 
their power to be higher precedence functions, and reduction of parentheses.  
Perhaps the only really neat feature of this dsl is the use of conjunctions, as 
the functions themselves are pretty simple.  At the same time, the conjunctions 
might get in the way if using these functions within forks.

the 3 core spreadsheet combiners:

to2 =: ( [: <"1 [: ,."0/&>/ [: i.@:>: each -~)
to =: 2 : 'm ,@:to2 n'
and=: ~.@:,&boxopen
less =: -.&boxopen

an example with amend:

'.#' {~ 1 (( 1 0 to 1 2 and 1 3 to 4 9 and 5 0 to 6 0 and 5 3) less (2 4 to 2 7 
and 1 1)) } 10 10 $ 0 
.......... 
#.######## 
...#....## 
...####### 
...####### 
#..#...... 
#......... 
.......... 
.......... 
..........

without conjunctions there would need to be many more parens

functions not part of the spreadsheet interface, include row/column 
intersections as the selection, and a utility to create a dyadic version of 
integers

  ito =: 2 : 'm ([ + [: i.@:>: -~) n' 
  2 ito 4 
2 3 4

  rc =: 2 : 'm ,@:([: <"1 ,."0/) n'
  2 ito 4 rc 1 3 
┌───┬───┬───┬───┬───┬───┐ 
│2 1│2 3│3 1│3 3│4 1│4 3│ 
└───┴───┴───┴───┴───┴───┘
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to