12. Reading and Writing
Translating to and from a known language provides useful
beginning exercises in learning a new one. The following provides
examples.
Cover the right side of the page and make
a serious attempt to translate the sentences on the left
to English; that is, state succinctly in English what the verb
defined by each sentence does. Use any available aids,
including the dictionary and experimentation on the computer:
f1=: <: | Decrement (monad); Less or equal |
f2=: f1&9 | Less or equal 9 |
f3=: f2 *. >:&2 | Interval test 2 to 9 (inclusive) |
f4=: f3 *. <. = ] | In 2 to 9 and integer |
f5=: f3 +. <. = ] | In 2 to 9 or integer |
g1=: %&1.8 | Divide by 1.8 |
g2=: g1^:_1 | Multiply by 1.8 |
g3=: -&32 | Subtract 32 |
g4=: g3^:_1 | Add 32 |
g5=: g1@g3 | Celsius from Fahrenheit |
g6=: g5^:_1 | Fahrenheit from Celsius |
h1=: >./ | Maximum over list (monad) |
h2=: h1-<./ | Spread. Try h2 b with the parabola: b=:(-&2 * -&3) -:i.12 |
h3=: h1@]-i.@[*h2@]%<:@[ | Grid. Try 10 h3 b |
h4=: h3 <:/ ] | Barchart. Try 10 h4 b |
h5=: {&' *' @ h4 | Barchart. Try 10 h5 b |
After entering the foregoing definitions, enter each
verb name alone to display its definition, and learn to
interpret the resulting displays. To see several forms of display,
first enter 9!:3 (2 4 5) .
Cover the left side of the page,
and translate the English definitions on the right
back into J.
Exercises
12.1 | These exercises are grouped by topic and organized like the section, with programs that are first to be read and then to be rewritten. However, a reader already familiar with a given topic might begin by writing. A. Properties of numbers
B. Coordinate Geometry Do experiments on the vector (or point) p=: 3 4
|