(format ,.y);(format +. r.y);(format +. 2 r.y) õýýýýýýýýÃýýýýýýýýýýýýýýýýÃýýýýýýýýýýýýýýýýÀ þ 0.000þ 1.000 0.000þ 2.000 0.000þ þ 0.785þ 0.707 0.707þ 1.414 1.414þ þ 1.571þ 0.000 1.000þ 0.000 2.000þ þ 2.356þ _0.707 0.707þ _1.414 1.414þ þ 3.142þ _1.000 0.000þ _2.000 0.000þ þ 3.927þ _0.707 _0.707þ _1.414 _1.414þ þ 4.712þ 0.000 _1.000þ 0.000 _2.000þ ÁýýýýýýýýÂýýýýýýýýýýýýýýýýÂýýýýýýýýýýýýýýýýã TAYLOR COEFFICIENT u t. 0 0 0 u t. y is the yth coefficient in the Taylor series approximation to the function u. The domain of the adverb t. is the same as the left domain of the derivative D. x u t.y is the product of (x^y) and u t. y . For example: f=. 1 2 1&p. [. g=. 1 3 3 1&p. x=. 10%~i=. i.8 ]c=. (f*g) t. i 1 5 10 10 5 1 0 0 6.2 ":(c p. x),:(f*g) x 1.00 1.61 2.49 3.71 5.38 7.59 10.49 14.20 1.00 1.61 2.49 3.71 5.38 7.59 10.49 14.20 (c p. x)=(f*g) x 1 1 1 1 1 1 1 1 ]d=. f@g t. i 4 12 21 22 15 6 1 0 (d p. x)=(f g x) 1 1 1 1 1 1 1 1 sin=. 1&o. [. cos=. 2&o. 8.4":t=. (^ t. i),(sin t. i),:(cos t. i) 1.0000 1.0000 0.5000 0.1667 0.0417 0.0083 0.0014 0.0002 0.0000 1.0000 0.0000 _0.1667 0.0000 0.0083 0.0000 _0.0002 1.0000 0.0000 _0.5000 0.0000 0.0417 0.0000 _0.0014 0.0000 * t 1 1 1 1 1 1 1 1 0 1 0 _1 0 1 0 _1 1 0 _1 0 1 0 _1 0 ((sin*sin)+(cos*cos)) t. i 1 0 0 0 _2.71051e_20 0 0 0 8.4": (^ t. i),:(1r2 t. i) 1.0000 1.0000 0.5000 0.1667 0.0417 0.0083 0.0014 0.0002 1.0000 0.5000 0.1250 0.0208 0.0026 0.0003 0.0000 0.0000 TAYLOR APPROXIMATION u T. n u T. n is the n-term Taylor approximation to the function u. For example: 6.2 ": ^ T. 8 x=. 2 %~ i.8 1.00 1.65 2.72 4.48 7.38 12.13 19.85 32.23 6.2 ": ^ x 1.00 1.65 2.72 4.48 7.39 12.18 20.09 33.12 ^ T. _ õýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýÃýÃýÀ þõýÃýÃýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýÀþ"þ0þ þþ3þ:þg +:^:(g ~: g@+:)^:_ ] 1 [. g=.p.&y.@(^ t.)@i.þþ þ þ þÁýÂýÂýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýãþ þ þ ÁýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýýÂýÂýã (^ = ^T._) i. 5 1 1 1 1 1 Compare the Taylor coefficient conjunction T. with the Taylor coefficient adverb t. . LEFT ARGUMENT x. x. denotes the left argument in an explicit definition, using the conjunction:. Since x. and y. may also be used as ordinary names, they may be used in experiments leading up to an explicit definition. For example: x.=. 3 [ y.=. 7 x.*y.-x. 12 text=. 'x.*y.-x.' do=. ". do text 12 f=. 3 : 0 : x.*y.-x. ) 3 f 7 12 10 f 17 70 RIGHT ARGUMENT y. y. denotes the right argument in an explicit definition, using the conjunction :. Since x. and y. may also be used as ordinary names, they may be used in experiments leading up to an explicit definition. For example: x.=. 3 [ y.=. 7 x.*y.-x. 12 text=. 'x.*y.-x.' do=. ". do text 12 f=. 3 : (':';text) 3 f 7 12 10 f 17 70 CONSTANT FUNCTIONS _9: to 9: _ _ _ The results are _9 and _8 and _7 and so on to 9. For example: x=. 1 2 3 [ y=. 4 5 6 2: y 2 x 9: y 9 The rank conjunction " applies to any noun to make a constant function of specified rank. The particular constant functions illustrated above are therefore special cases of the form i"_ . For example: 2"_ y 2 2"0 y 2 2 2 2"1 i. 2 3 4 2 2 2 2 2 2 2p1"0 y 6.28319 6.28319 6.28319 1p1 1p_1 1x1"0 y A constant function with a vector result 3.14159 0.3183099 2.71828 3.14159 0.3183099 2.71828 3.14159 0.3183099 2.71828 0 0 0"1 y The zero vector in a space of three dimensions 0 0 0 CONSTANTS The form of a numeric constant defined and illustrated in Part I is elaborated by the use of further letters, as in 2r3 for two-thirds, 2p1 for two pi, and 2r3p1 for two-thirds pi. The complete scheme of numeric constants obeys the following hierarchy : . The decimal point is obeyed first _ The negative sign is obeyed next e Exponential (scientific) notation r Rational number ad ar j Complex (magnitude and angle) in degrees or radians ; Complex number p x Numbers based on pi (o.1) and on Eulers number (the exponential ^1) b Base value (using a to z for 10 to 35) For example, 2.3 denotes two and three-tenths and _2.3 denotes its negation; but _2j3 denotes a complex number with real part _2 and imaginary part 3, not the negation of the complex number 2j3. Furthermore, symbols at the same level of the hierarchy cannot be used together: 1p2x3 is an ill-formed number. The following lists illustrate the main points: 2.3e2 2.3e_2 2j3 2r3 230 0.023 2j3 0.666667 2p1 1r2p1 1r4p1 1p_1 6.28319 1.5708 0.785398 0.31831 1x2 2x1 1x_1 7.38906 5.43656 0.367879 2e2r4j2e2r2 2e2r4j2e2r2p1 2ad45 2ar0.785398 50j100 157.08j314.159 1.41421j1.41421 1.41421j1.41421 16b1f 10b23 _10b23 1r10b23 1e2b23 2b111.111 31 23 _17 3.2 203 7.875 Negative integers following p and x indicate the use of reciprocals. For example, 2p_2 is two divided by pi squared, and 2x_2 is two divided by the square of Eulers number. REFERENCES 1. Falkoff, A. D., and K. E. Iverson, The Design of APL, IBM Journal of R&D, July, 1973. 2. " , The Evolution of APL, ACM Sigplan Notices, August 1978. 3. Iverson, K.E., A Dictionary of APL, ACM APL Quote-Quad, September, 1987. 4. McIntyre, D.B., Language as an Intellectual Tool: From Hieroglyphics to APL, IBM Systems Journal, December, 1991. 5. Iverson, K.E., A Personal View of APL, IBM Systems Journal, December, 1991. 6. Hui, R.K.W., An Implementation of J, ISI, 1992. 7. Burke, C. J User Manual, ISI, 1994. 8. Iverson, K.E., Tangible Math, ISI, 1991 9. " , Arithmetic, ISI, 1991 10. " , Calculus, ISI, 1994 11. McDonnell, E.E., Complex Floor, APL73, ACM 12. McDonnell, E.E., Zero Divided by Zero, APL76, ACM 13. Bernecky, Robert, and R.K.W. Hui, Gerunds and Representations, APL91, ACM ACKNOWLEDGMENTS I am indebted to Roger Hui for his rapid development of a flexible, reliable, and highly portable implementation of J, for his close collaboration in the design of the language, for critical reading of successive drafts of the dictionary, and for significant contributions to the treatments of certain topics, in particular, the identity functions. I am also indebted to Eric Iverson for the design and implementation of locatives, control structures, and the Windows interface. Copyright Author: Kenneth E. Iverson J Introduction and Dictionary Copyright 1991 - 1995 All Right Reserved Iverson Software Inc. 33 Major Street Toronto, Ontario Canada M5S 2K9 ISBN 1-895721-08-3 Foreign Conjunction The conjunction !: applies to integer scalar left and right arguments to produce verbs, with the exception that the case 5!:0 produces an adverb. These verbs behave like any other verb: they may be assigned names, may serve as arguments to adverbs and conjunctions, and must be used with an argument even though (as in 6!:0 '') it may have no significance. Where these verbs take names as arguments, the names are boxed, as in 4!:55 'a';'bc' to erase the names a and bc. A bracketed left argument indicates that it is optional. 0 Scripts 1 Files 2 Host 3 Storage Types 4 Name Classes and Lists 5 Representations 6 Time 7 Space 8 Screens, Fonts and Edit 9 Global Parameters 11 Window Driver 13 Debug 14 Data Driver 15 Dynamic Link Library 128 Numerical Functions 0 Scripts [x] 0!:k y The script y is executed according to the digits (zero or one) in the 3-digit decimal representation of k, and the resulting execution log is appended to the file named x (if specified): 1st digit 2nd digit 3rd digit 0 From file or noun Stop on error Silent 1 From noun Continue on error Display For example, 0!:111 abc executes the noun abc, completes, and displays. If y is 1, input is from the keyboard: (<'f2')0!:1(1) files the execution log in f2. [x] 0!:2 y tests a script that is expected to be a sequence of tautologies; it is like 0!:1, but stops if any result is other than all 1s. Sessions begin with (silent, stop) execution of 0!:0<'profile.js' 1 Files Except as otherwise noted, a file may be specified by a name (such as <'sub\abc.q') or by an integer file number obtained from open ( 1!:21á<'sub\abc.q'). 1!:0 y Directory. y is a string of the path search expression (a boxed string is also accepted); the result is a 5-column table of the file name, modification time, size, permission, and attributes, individually boxed. For example, try 1!:0 '*.*'. The permission and attribute columns are system dependent. For example, in DOS and Windows: 1!:0 'jsm.exe' õýýýýýýýÃýýýýýýýýýýýýýýýýýýÃýýýýÃýýýÃýýýýýýÀ þjsm.exeþ1994 10 31 3 57 46þ3125þrwxþ-----aþ ÁýýýýýýýÂýýýýýýýýýýýýýýýýýýÂýýýýÂýýýÂýýýýýýã Permission is a 3-letter string indicating the read, write, and execute permissions. Attributes is a 6-letter string indicating read-only, hidden, system, volume label, directory, and archive. 1!:1 y Read. y is a file name, file number, or the number 1 (indicating the keyboard); the result is a string of the file contents. For example, try 1!:1 <'abc.q' x 1!:2 y Write. x is a string of the new contents of the file; y is a file name, or number, or the number 2 for screen output x 1!:3 y Append. like x 1!:2 y, but appends rather than replaces 1!:4 y Size 1!:5 y Create directory: y is a (boxed) directory name [x] 1!:6 y Query/Set Attributes [x] 1!:7 y Query/Set Permissions 1!:11 y Indexed Read. y is a list of a boxed file name (or number) and a boxed index and length. The index may be negative. If the length is elided, the read goes to the end. For example: 1!:11 'abc.x';1000 20 f=. 1!:21 <'abc.x' 1!:11 f,1000 20 x 1!:12 y Indexed Write. Like indexed read; x specifies the string to be written 1!:20 y File Numbers and Names. A 2-column table of the open file numbers and names. (The argument y is required but ignored) 1!:21 y Open. Open file named y, creating it if necessary; the result is a file number 1!:22 y Close. Close file named or numbered y. Any locks are released 1!:30 y Locks. A 3-column integer table of the file number, index, and length of file locks. The argument y is required but ignored 1!:31 y Lock. y is a 3-element integer vector of the file number, index, and length of the file region to be locked; the result is 1 if the request succeeded, and 0 if it did notá 1!:32 y Unlock. y is a 3-element integer vector of the file number, index, and length of the file region to be unlocked 1!:55 y Erase File/Directory. e.g., 1!:55<'careful' 2 Host Commands 2!:0 y Host. The list y is executed by the host system, and the result is returned. For example, 2!:0 'dir *.exe' . Not available for Windows or Macintosh 2!:1 y Spawn. Like 2!:0, but yields '' without waiting for the host to finish. Any output is ignored. For example, 2!:1 can be used to invoke a text-editor. Not available for Windows or Macintosh 2!:55 y Terminate session. y is an integer return code 3 Storage Types 3!:0 y Type. Type of the noun y, encoded as 2^i.6 for boolean, literal, integer, floating, complex, boxed 3!:1 y Convert to binary representation. A string of the binary representation of a noun y. The result is machine-dependent 3!:2 y Convert from binary representation. Inverse of 3!:1 and of 3!:3 3!:3 y Hex representation. Like 3!:1, but the result is a literal matrix of the hexadecimal representation 3!:4 y If ic=. 3!:4 (integer conversion) and fc=. 3!:5 3!:5 y (floating conversion), then: 2 ic y is J integers to binary long integers _2 ic y binary long integers to J integers 1 ic y J integers to binary short integers _1 ic y binary short integers to J integers 0 ic y binary unsigned short integers to J integers 2 fc y is J floats to binary doubles _2 fc y binary doubles to J floats 1 fc y J floats to binary short floats _1 fc y binary short floats to J floats All ranks are infinite and all inverses of k&ic and k&fc exist 4 Name Classes and Lists 4!:0 y Class. Class of (boxed) name: _2 if unused, _1 if not valid, and 0 to 3 for noun, adverb, conjunction, verb, and 6 for locale [x] 4!:1 y List. Result is a vector of boxed names belonging to the classes 0 to 3 as defined under 4!:0. The optional left argument lists the initial letters of names to be included 4!:3 y Scripts. List of script names that have been invoked using 0!: (The argument y is required but ignored) 4!:4 y Script Index. Index (in 4!:3 '') of script that defined y 4!:55 y Erase 5 Representatons 5!:1 <'y' yields the atomic (or gerundial) representation of any named entity. The result is a single box containing a one- or two-element list of boxed characters (that may be further boxed). For example: 5!:1 <'n' [. f=. +/ . * [. n=. 1 2 3 õýýýýýýýýýÀ þõýÃýýýýýÀþ þþ0þ1 2 3þþ þÁýÂýýýýýãþ Áýýýýýýýýýã 5!:1 <'f' õýýýýýýýýýýýýýýýÀ þõýÃýýýýýýýýýýýÀþ þþ.þõýýýýýýýÃýÀþþ þþ þþõýÃýýýÀþ*þþþ þþ þþþ/þõýÀþþ þþþ þþ þþþ þþ+þþþ þþþ þþ þþþ þÁýãþþ þþþ þþ þþÁýÂýýýãþ þþþ þþ þÁýýýýýýýÂýãþþ þÁýÂýýýýýýýýýýýãþ Áýýýýýýýýýýýýýýýã The atomic representation is used in the representation of gerunds, and three further representations, 5!:2 (Boxed), 5!:4 (Tree), and 5!:5 (Linear) are also based upon it. The structures of all may be best appreciated from the tree form (which uses the box-drawing characters controlled by 9!:6 and 9!:7). For example: 5!:4 <'nub' [. nub=. (i.@# = i.~) # ] õý i. õý @ ýÂý # õýýýÊý = þ Áý ~ ýýý i. ýýÊý # Áý ] The linear representation is a string which, when interpreted, produces the named object. For example: 5!:5 <'a' [ a=. o. i. 3 4 3.14159265358979324*i.3 4 For all but the noun case, the default displays established by 9!:3 provide convenient experimentation with all representations. For example: 9!:3 (5 4 2 1) cube=. ^&3 cube ^&3 õý ^ ýý & ýÂý 3 õýÃýÃýÀ þ^þ&þ3þ ÁýÂýÂýã õýýýýýýýýýýýýýÀ þõýÃýýýýýýýýýÀþ þþ&þõýÃýýýýýÀþþ þþ þþ^þõýÃýÀþþþ þþ þþ þþ0þ3þþþþ þþ þþ þÁýÂýãþþþ þþ þÁýÂýýýýýãþþ þÁýÂýýýýýýýýýãþ Áýýýýýýýýýýýýýã 6 Time 6!:0 y Current. in order YMDHMS (with fractional seconds). 6!:1 y Session. Seconds since start of session [x] 6!:2 y Execute. Seconds to execute sentence y (mean of x times with default once) 6!:3 y Delay . for y seconds. For example, 6!:3 (60) 7 Space 7!:0 y Current. Amount of space currently in use