Contents
Foreword. ii
Acknowledgements. iii
Change History. iii
1. Introduction. 1
Programming In J 2
2. Preliminaries. 3
Notation. 3
Terminology. 3
Sentences (statements) 4
Word Formation (tokenizing rules) 4
Numbers. 5
Characters. 5
Valence of Verbs (Binary and Unary
Operators) 5
How Names (Identifiers) Get Assigned. 6
Order of Evaluation. 7
What a verb (function) looks like. 7
Running a J program.. 8
Interrupting Execution. 9
Errors. 10
Names Defined at Startup. 10
Step-By-Step Learning: Labs. 10
J Documentation. 10
Getting Help. 11
3. A First Look At J Programs. 12
Average Daily Balance. 12
Calculating Chebyshev Coefficients. 15
4. Declarations. 17
Arrays. 17
Cells. 18
Choosing Axis Order 19
Negative Cell-Rank; Items. 19
Lists. 19
Phrases To Memorize. 20
Constant Lists. 20
Array-creating verbs. 20
Dyad $ ($hape) and monad $ ($hape Of) 20
Monad # (Tally) 25
Monad i. (Integers) 25
5. Loopless Code I—Verbs Have Rank. 27
Examples of Implicit Loops. 27
The Concept of Verb Rank. 29
Verb Execution—How Rank Is Used (Monads) 29
Controlling Verb Execution By Specifying a Rank. 31
Examples Of Verb Rank. 32
fndisplay—A Utility for Understanding Evaluation. 35
Negative Verb Rank. 36
Verb Execution—How Rank Is Used (Dyads) 37
Concatenating Lists: Dyad , (Append) 39
When Dyad Frames Differ: Operand Agreement 40
Order of Execution in Implied Loops. 44
A Mistake To Avoid. 44
6. Starting To Write In J. 46
7. More Verbs. 49
Arithmetic Dyads. 49
Boolean Dyads. 50
Min and Max Dyads. 50
Arithmetic Monads. 50
Boolean Monad. 51
Operations on Arrays. 51
Dyads. 51
Monads. 56
8. Loopless Code II—Adverbs /
and ~.. 60
Modifiers. 60
The Adverb Monad u/.. 60
The adverb ~. 62
9. Continuing to Write in J. 64
10. Compound Verbs. 70
Verb Sequences—u@:v and u@v.. 70
The Difference Between u@:v and u@v.. 71
Making a Monad Into a Dyad: The Verbs [ and ] 72
Making a Dyad Into a Monad: u&n
and m&v.. 72
11. Boxing (structures) 75
Terminology. 77
Boxing As an Equivalent For Structures In C.. 78
12. Empty Operands. 79
Execution On a Cell Of Fills. 79
Empty cells. 81
If Fill-Cells Are Not Enough. 81
13. Loopless Code III—Adverbs \
and \... 82
14. Verbs for Arithmetic. 85
Dyads. 85
Monads (all rank 0) 86
15. Loopless Code IV.. 87
Power/If/DoWhile Conjunction u^:n
and u^:v.. 88
Tie and Agenda (switch) 90
The Tie Conjunction u`v u`n m`v m`n.. 90
The Agenda (switch) conjunction m@.v.. 91
16. More Verbs For Boxes. 93
Dyad ; (Link) And Monad ; (Raze) 93
Dyad , Revisited—the Case of Dissimilar Items. 95
Verbs With More Than 2 Operands—Multiple Assignment 95
Dyad { Revisited. 96
Split String Into J Words: Monad ;:.. 99
Fetch From Structure: Dyad {::.. 99
Report Boxing Level: Monad L... 100
17. Verb-Definition Revisited. 102
What really happens during m :n and verb define.. 102
Compound Verbs Can Be Assigned. 103
Dual-Valence verbs: u :v.. 104
The Suicide Verb [:.. 104
Multi-Line Comments Using 0 :0.. 105
Final Reminder 105
18. u^:_1, u&.v, and u :.v.. 106
The Obverse u^:_1.. 106
Apply Under Transformation: u&.v
and u&.:v.. 106
Defined obverses: u :.v.. 108
u&:v and u&v.. 108
An observation about dyadic verbs. 109
19. Performance: Measurement & Tips. 110
Timing Individual Sentances. 110
Compounds Recognized by the Interpreter 112
Use Large Verb-Ranks! and Integrated Rank Support 113
Shining a Light: The J Performance Monitor 114
20. Input And Output 117
Foreigns. 117
File Operations 1!:n; Error Handling. 117
Error Handling: u ::v, 13!:11, and 9!:8.. 118
Treating a File as a Noun: Mapped Files. 118
Format Data For Printing: Monad And Dyad ":.. 119
Monad ":.. 120
Format binary data: 3!:n.. 121
printf,
sprintf, and qprintf.. 122
Convert Character To Numeric: Dyad "... 122
21. Calling a DLL Under Windows. 123
Memory Management 124
Aliasing of Variables. 125
Aliasing of Mapped Nouns. 125
Aliasing of DLL Operands. 126
22. Socket Programming. 127
sdselect.. 127
Asynchronous Sockets and socket_handler.. 127
Names and IP Addresses. 128
Connecting. 129
Listening. 129
Other Socket Verbs. 130
Datagrams. 130
Socket Options. 130
Housekeeping. 131
23. Loopless Code V—Partitions. 132
Find Unique Items: Monad ~. and Monad ~:.. 132
Apply On Subsets: Dyad u/... 132
Apply On Partitions: Monad u;.1 and u;.2.. 134
Apply On Specified Partitions: Dyad u;.1
and u;.2.. 135
Find Sequence Of Items: Dyad E... 136
Apply On Subarray: Dyad u;.0.. 137
Apply On All Subarrays: Dyad u;.3
and u;._3.. 138
24. When Programs Are Data. 140
Calling a Published Name. 140
Using the Argument To a Modifier 140
Invoking a Gerund: m`:6.. 141
Passing the Definition Of a Verb: 128!:2
(Apply) 142
Passing an Executable Sentence: Monad ".
and 5!:5.. 143
25. Loopless Code VI 144
26. Modifying an array: m}.. 148
Modification In Place. 149
27. Control Structures. 151
for./do./end. and for_x./do./end... 151
while./do./end. and whilst./do./end... 151
if./do./else./end., if./do./elseif./do./end... 151
try./catch./end. and catcht./throw... 152
select./case./fcase./end... 152
return... 153
assert... 153
28. Modular Code. 154
Locales And Locatives. 154
Assignment 154
Name Lookup. 155
Changing The Current Locale. 156
The Shared Locale 'z'.. 159
Using Locales. 159
29. Writing Your Own Modifiers. 161
Modifiers That Do Not Refer To x. Or
y... 161
Example: Creating an Operating-System-Dependent Verb. 162
Example: The
LoopWithInitial Conjunction. 163
Example: A Conjunction that Analyzes u and
v.. 163
An Exception: Modifiers that Do Not Refer to u. or v... 165
Modifiers That Refer To x. Or y... 165
30. Applied Mathematics in J. 168
Complex Numbers. 168
Matrix Operations. 168
Polynomials: p... 169
Calculus: d., D., D:, and p.... 170
Taylor Series: t., t:, and T... 171
Hypergeometric Function with H... 171
Sparse Arrays: Monad and Dyad $... 172
Random Numbers: ?.. 172
Plot 172
Computational Addons. 173
Useful Scripts Supplied With J. 173
31. Elementary Mathematics in J. 174
Verbs for Mathematics. 174
Extended Integers, Rational Numbers, and x:.. 174
Factors and Primes: Monad p:,
Monad and Dyad q:.. 175
Permutations: A. and C... 175
32. Odds And Ends. 177
Dyad # Revisited. 177
Boxed words to string: Monad ;:^:_1.. 177
Spread: #^:_1.. 177
Choose From Lists Item-By-Item: monad m}.. 177
Recursion: $:.. 178
Make a Table: Adverb dyad u/.. 178
Boolean Functions: Dyad m b... 179
Functions on Boolean operands. 179
Bitwise Boolean Operations on Integers. 180
Operations Inside Boxes: u L: n, u S: n.. 180
Comparison Tolerance !.f.. 182
Right Shift: Monad |.!.f.. 183
Generalized Transpose: Dyad |:.. 183
Monad i: and Dyad i:.. 184
Fast String Searching: s: (Symbols) 184
Unicode Characters: u:.. 186
Window Driver And Form Editor 186
Tacit Programming 187
33. Tacit Programs. 188
34. First Look At Forks. 190
35. Parsing and Execution I 192
36. Parsing and Execution II 195
The Parsing Table. 195
Examples Of Parsing And Execution. 196
Undefined Words. 200
37. Forks, Hooks, and Compound Adverbs. 201
Tacit and Compound Adverbs. 204
Referring To a Noun In a Tacit Verb. 205
38. Readable Tacit Definitions. 206
Flatten a Verb: Adverb f... 206
Using f. to improve performance. 207
39. Explicit-To-Tacit Converter 209
Special Verb-Forms Used in Tacit Definitions. 210
40. Valedictory. 211
41. Glossary. 212
42. Error Messages. 216
43. Index. 218