For me the flavor of J is functions (verbs), operators (adverbs and 
conjunctions), and arrays: the J programmer thinks at this level of abstraction 
to solve his problems, and the extended example below intends to give visitors 
a 
taste of this flavor.

However, this omits the use of J for windows programming.  How would you 
describe the J flavor of that, and what taste would you give visitors?

Here is my extended taste of "functions, operators, arrays" for a visitor.

    ]L =: i. 4   NB. assign (=:) and display (]) a "line" (vector) of 4 integers
0 1 2 3

    ]P =: i. 2 4   NB. a two-line "page" (matrix)
0 1 2 3
4 5 6 7

    ]B =: i. 3 2 4   NB. a three page "book" (array)
  0  1  2  3
  4  5  6  7

  8  9 10 11
12 13 14 15

16 17 18 19
20 21 22 23

    L      NB. show L
0 1 2 3

    +/ L   NB. operator / inserts function + between items, we see sum
6

    P
0 1 2 3
4 5 6 7

    +/ P   NB. items of a page are its lines, we see the sum of two lines
4 6 8 10

    B
  0  1  2  3
  4  5  6  7

  8  9 10 11
12 13 14 15

16 17 18 19
20 21 22 23

    +/ B   NB. items of a book are its pages, we see sum of three pages
24 27 30 33
36 39 42 45

    L      NB. show L
0 1 2 3

    +/\ L  NB. operator \ applies +/ to "prefixes", gives cumulative sums
0 1 3 6

    P
0 1 2 3
4 5 6 7

    +/\ P
0 1 2  3
4 6 8 10

    B
  0  1  2  3
  4  5  6  7

  8  9 10 11
12 13 14 15

16 17 18 19
20 21 22 23

    +/\ B
  0  1  2  3
  4  5  6  7

  8 10 12 14
16 18 20 22

24 27 30 33
36 39 42 45

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

Reply via email to