<<     >>     Contents     Help    

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

The Execution Window; Script Windows. 10

Names Defined at Startup. 10

Step-By-Step Learning: Labs. 11

J Documentation. 11

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. 57

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

A Few J Tricks. 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 Sentences. 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

Multidimensional Partitions. 137

Apply On Subarray: Dyad u;.0.. 137

Apply On All Subarrays: Dyad u;.3 and u;._3.. 138

Extracting Variable-Length Fields Using ^: and ;.1.. 139

24. When Programs Are Data. 141

Calling a Published Name. 141

Using the Argument To a Modifier 141

Invoking a Gerund: m`:6.. 142

Passing the Definition Of a Verb: 128!:2 (Apply) 143

Passing an Executable Sentence: Monad ". and 5!:5.. 144

25. Loopless Code VI 145

26. Loopless Code VII—Sequential Machines. 149

27. Modifying an array: m}.. 152

Monad I.—Indexes of the 1s in a Boolean Vector 153

Modification In Place. 154

28. Control Structures. 155

for./do./end. and for_x./do./end... 155

while./do./end. and whilst./do./end... 155

if./do./else./end., if./do./elseif./do./end... 155

try./catch./end. and catcht./throw... 156

select./case./fcase./end... 156

return... 157

assert... 157

29. Modular Code. 158

Locales And Locatives. 158

Assignment 158

Name Lookup. 159

Changing The Current Locale. 160

The Shared Locale 'z'.. 163

Using Locales. 163

30. Writing Your Own Modifiers. 165

Modifiers That Do Not Refer To x. Or y... 165

Example: Creating an Operating-System-Dependent Verb. 166

Example: The LoopWithInitial Conjunction. 167

Example: A Conjunction that Analyzes u and v.. 167

An Exception: Modifiers that Do Not Refer to u. or v... 169

Modifiers That Refer To x. Or y... 169

31. Applied Mathematics in J. 172

Complex Numbers. 172

Matrix Operations. 172

Polynomials: p... 173

Calculus: d., D., D:, and p.... 174

Taylor Series: t., t:, and T... 175

Hypergeometric Function with H... 175

Sparse Arrays: Monad and Dyad $... 176

Random Numbers: ?.. 176

Plot 177

Computational Addons. 177

Useful Scripts Supplied With J. 177

32. Elementary Mathematics in J. 178

Verbs for Mathematics. 178

Extended Integers, Rational Numbers, and x:.. 178

Factors and Primes: Monad p:, Monad and Dyad q:.. 179

Permutations: A. and C... 179

33. Odds And Ends. 181

Dyad # Revisited. 181

Boxed words to string: Monad ;:^:_1.. 181

Spread: #^:_1.. 181

Choose From Lists Item-By-Item: monad m}.. 181

Recursion: $:.. 182

Make a Table: Adverb dyad u/.. 182

Boolean Functions: Dyad m b... 183

Functions on Boolean operands. 183

Bitwise Boolean Operations on Integers. 184

Operations Inside Boxes: u L: n, u S: n.. 184

Comparison Tolerance !.f.. 186

Right Shift: Monad |.!.f.. 187

Generalized Transpose: Dyad |:.. 187

Monad i: and Dyad i:.. 188

Fast String Searching: s: (Symbols) 188

Unicode Characters: u:.. 190

Window Driver And Form Editor 190

Tacit Programming  191

34. Tacit Programs. 192

35. First Look At Forks. 194

36. Parsing and Execution I 196

37. Parsing and Execution II 199

The Parsing Table. 199

Examples Of Parsing And Execution. 200

Undefined Words. 204

38. Forks, Hooks, and Compound Adverbs. 205

Tacit and Compound Adverbs. 208

Referring To a Noun In a Tacit Verb. 209

39. Readable Tacit Definitions. 210

Flatten a Verb: Adverb f... 210

Using f. to improve performance. 211

40. Explicit-To-Tacit Converter 213

Special Verb-Forms Used in Tacit Definitions. 214

41. Common Mistakes. 215

Mechanics. 215

Programming Errors. 216

42. Valedictory. 219

43. Glossary. 220

44. Error Messages. 224

45. Index. 226

 



<<     >>     Contents     Help