Newsgroups: comp.lang.apl
Path: watmath!watserv1!utgpu!news-server.csri.toronto.edu!rpi!think.com!sdd.hp.com!decwrl!wupost!csus.edu!sfsuvax1.sfsu.edu!vpcsc4
From: vpcsc4@sfsuvax1.sfsu.edu (Emmett James McLean)
Subject: Simple J questions
Message-ID: <1991Sep1.225152.22316@csus.edu>
Sender: news@csus.edu
Organization: San Francisco State University
Distribution: NA
Date: Sun, 1 Sep 1991 22:51:52 GMT

These questions are probably answered in the book "Programming in J",
but I understand that it may be a while before I get my copy since
there is currently a mail strike in Canada.


If I type the following J command

	a=. 2 2 $ 1+i.4

	a
    1  2
    3  4

And,

    b =. 0.7  0.9  0.2 0.25

How do I get:

1:
    1  4
    3  8	   (Multiply the 2nd column by 2)

2:
    1  4 
    6  8       (Multiply the 2nd row by 2)

3:
    1  2  1  2
    3  4  3  4

4:
    1 16
    3  4       (Change element 2 to 16)

5:
    3  7       (Add across the columns)

6:
    0.7  0.9
    0.2  0.25  (Use the array of a to index into b)

Similiarly, if :

    a=. 2 2 2 $1+i. 8

    a
      1  2
      3  4
  
      5  6
      7  8

How do I get ?:

7:
      2  4  (Multiply the top item by 2)
      6  8

      5  6
      7  8

8:
      1  4  (Multiply the right column by 2 in both items)
      3  8

      5  12
      7  16 

9:
      3 7 11 15  (Add across the columns) 
