Just recording random discoveries as I work through the EasyJ book. Read if all that interested in how I think ...

I’m working my way through the book EasyJ, by Alvord and Thomson, available in PDF on the jsoftware site. As I do so, I’m trying to do at least these things:

• Remember the verbs they talk about, their names, what they do;
• Experiment with them to get a feeling for them;
• Think about my target app (still bowling), and how the stuff they're talking about might fit in.

I’ve decided to log bits of what I learn here, with the hope that readers may find it interesting to see how someone tries to learn this stuff, and with the hope that some of what I record here will be useful to me later on in the learning effort.

EasyJ takes you through the usual warmup of 2 + 2, and 2 3 4 + 4 5 6 and such. Then they introduce comparators and boolean operations like and (*.) and so on.

All the time, I’m thinking of bowling. Not the game, mind you. You couldn’t get me to go bowling unless you’re awfully good looking. Scoring bowling. It’s a nice little manipulation in any language, and I’m getting the sense that a solution in J can be pretty interesting.

I have a random game that I made up, not a very good test but good enough:

`r =. 4 5 4 5 10 4 5 4 5 4 5 4 5 4 5 4 5 4 5`

` ` I’m still thinking it would be interesting to wrap the game into rows, one for each frame, and with an extra column that would contain a bonus ball if applicable.  So I started thinking “where are the 10s”, which is answered by

`r=10`

` ` which returns

`0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0`

` ` That made me think about where are the fives, just because there are more of them:

```r=5
0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1```

` ` I can get all the fives out, via

```(r=5)#r
5 5 5 5 5 5 5 5 5```

` ` But that’s not very interesting, though worth remembering. I was thinking that the indexes of the tens (or fives in this example) might be interesting … and realized that if I did the # operation on the numbers from 0 to the size of r, that would do the job:

```(r=5)#i.#r
1 3 6 8 10 12 14 16 18```

` ` So that actually is slightly interesting. The indexes of values I want could be used in each row of my planned matrix above, to pull out the scores at those positions. Then I could add up each row and get the frame score.

Or, it may just suffice to pull the desired values and then compress out the zeros. Or, perhaps no need to compress out the zeros.

One more thing. I note in the expression above, r occurs twice. There is almost certainly a way to build a function that takes r as a parameter, and uses it twice. J calls those “hooks” or “forks”. I’m not up to creating one yet. At least not now. My brain is full for now.