J For Idiots by Robert Ames J is a general purpose interpreted language. 'INTERPRETED' means that you get an answer right away. So let's get right into it... ================================================================== LESSON 1 : Addition and Subtraction ================================================================== How much is one plus one? 1 + 1 2 Notice the answer is given on the left 2+3 5 2 + 4 6 5+4+3+2+1 15 2+(3+4) 9 (2+3)+4 9 a=. 4 The value 4 is assigned to 'a' b=. 5 The value 5 is assigned to 'b' In J, data such as '4' and '5' are termed 'nouns'. Names which hold data values are termed 'pronouns'. In this case, 'a' and 'b' are pronouns. a 4 b 5 a+b 9 b+a 9 1.5 + 2.5 4 3.33333333333333 + 4.111111111111111 7.44444 Notice the limits on precision million=. 1000000000 million+million+million 3e9 '3e9' is scientific notation meaning '3 times 10 to the ninth power' 123456789.123456789 + 123456789.123456789 2.46914e8 We can see from the example above that precision is to 5 decimal places ================================================================== NEGATIVES and SUBTRACTION ================================================================== 5-4 1 4-5 _1 Note that the underscore is used to denote a negative quantity. -5 _5 -2.3 _2.3 Now watch: -.5 ) _4 ) .5 ) +-+-+ ) This is probably not what you want. |.|5| ) +-+-+ ) 2-.5 ) 2 ) As you will see from these examples, you must precede a fraction less than 1 with a zero, otherwise there will be undesirable effects. -0.5 ) _0.5 ) 0.5 ) Better, right? 0.5 ) 2-0.5 ) 1.5 ) (2+3)-4 1 2+(3-4) 1 ================================================================== END OF LESSON 1 ==================================================================