Marry, pray, Whichcraft in J!

Here is some practice material for beginning and advanced J programmers alike. Just in case it happens to be the start of the week and you're looking for some distraction from Real Work ;-)

Martin Neitzel

While reading Roger Hui's "Rank and Uniformity" from the APL95 proceedings, I came across the following funky phrase that I did understand immediately:

[ ^: some_comparison

If this isn't already an old hat to you, you're invited to sharpen your J skills a little bit on this small but useful phrase, too.

Predict the results of

17 ([^:<) 4 and 17 ([^:<) 21

Substitute ] for [ and/or > for < .

This will give you a good impression of what it does. If you cheated on the predictions, figure now out how it works. Look up the definitions of Left "[", Less Than "<", and Power "^:". What kind of train is [^:< , and where do the arguments go?

In general you'll use more complicated boolean relationships r in [^:r (Roger needed a <&# in his article.) The phrase makes it also easy to to look for extremes in larger data sets. Just use [^:r/ on (non-empty) item lists.

You are a seasoned Juggler and are bored so far? Then quick!, either without or with consulting the Dictionary, but without experiments:

The first is by Ken Iverson and can be found in the dictionary entry for \. , for computing the (boxed) minors of a matrix:

minors=: 1&(|:\.)"2^:2 <"2 minors i.3 3

The second is by Kirk Iverson and can be found in the page http://www.jsoftware.com/chal/soln006.html as the solution to J Challenge #6. The problem is to border an array y by scalar x in every dimension, and Kirk's solution is:

(The expression is explained in detail on that page.) One might

Fri, 16 Oct 1998 03:00:00 GMT

Roger Hu#4 / 4

Marry, pray, Whichcraft in J!

Henry Rich writes on Monday, April 29:

Quote:

> Very interesting. And I tried

> (2&[) b. _1

> How did the interpreter pick that for an inverse?

J uses a linear approximation in the absence of a known inverse, as above. We have had second thoughts about having this default and have removed it in favor of a domain error, to take effect in the next release.