((<.&.-);(>.)) 4.6 4 _4 _4.6 õıııııııııÃıııııııııÀ ş5 4 _4 _4ş5 4 _4 _4ş ÁıııııııııÂıııııııııã Increment >: _ 0 0 Larger or Equal >:y is y+1. For Example: >: 2 3 5 7 3 4 6 8Also see Not (-.) x>:y is 1 if x is tolerantly greater than or equal to y. See Equal (=) for a discussion of tolerance. >:!.t uses tolerance t. +: i. 6 Even numbers 0 2 4 6 8 10 >: +: i. 6 Odd numbers 1 3 5 7 9 11 odds=. >:@+:@i. odds 10 1 3 5 7 9 11 13 15 17 19 +/ odds 10 100 (+/@odds , *:) 10 Sum of first n odds equals the square of n. 100 100 Negative Sign and Infinity _ The symbol _ followed by a digit denotes a negative number (as in _3.4), and denotes infinity when used alone, or negative infinity (in __ ). It is also used in names, as discussed in Part I and in Part II Section H. For example: 2 % 0 Two divided by zero _ 10 ^. 0 Base ten logarithm of zero __ _2 _ 3+5 3 _ 8 integer_test=. =<. Use of break in name integer_test 3 3.5 1 0 Although -2 may sometimes be used instead of _2, it is important to understand that the former is the application of a function to the number 2, whereas the symbol _ is an indivisible part of the number representation, just as the period is an indivisible part of a number such as 8.9. Indeterminate _. The indeterminate _. results from expressions such as _-_ (infinity minus infinity) and from expressions (such as 3+_.) in which an indeterminate argument occurs. Infinity _: _ _ _ Infinity _: is a constant function that yields an infinite result, that is, _: y is _ _: is a constant function that yields an infinite result, that is, x_:y is _ For example: y=. 1 2 3 4 _: y _ _:"0 y Rank zero applies to each element _ _ _ _ Other constant functions include _9: and _8: etc. to 9:. More generally, the expression x"r defines a constant function of rank r that yields the constant value x . For example, 3.14"0 y 3.14 3.14 3.14 3.14 3.14"1 y 3.14 The specific constant functions mentioned can therefore be written alternatively as _"_ and _9"_ and 0"_ and 9"_ , etc. Conjugate + _ 0 0 Plus + y is the conjugate of y. For example, +3j4 is 3j_4 . + is defined as in elementary arithmetic, and is extended to complex numbers as usual. A complex number y multiplied by its conjugate produces a real number equal to the square of its magnitude |y. For example: 3j4 * 3j_4 25 The function j. multiplies its argument by the square root of negative one. For example: ]i=. i. 5 0 1 2 3 4 j. i 0 0j1 0j2 0j3 0j4 y=. i + 2 * j. i y 0 1j2 2j4 3j6 4j8 +y 0 1j_2 2j_4 3j_6 4j_8 y * +y 0 5 20 45 80 %: y * +y 0 2.23607 4.47214 6.7082 8.94427 |y 0 2.23607 4.47214 6.7082 8.94427 The conjugate of y can also be expressed as (|y*y)%y. For example: (|y*y)%y 0 1j_2 2j_4 3j_6 4j_8 Real / Imaginary +. _ 0 0 GCD (Or) +.y yields a two-element list of the real and imaginary parts of its argument. For example, +.3j5 is 3á5, and +.3 is 3á0. Applied to a list, +. produces a table of the two-element results. x +. y is the greatest common divisor of x and y. If the arguments are boolean (0 or 1), the functions +. and *. are equivalent to logical or and and. The function -. similarly restricted is not. ]y=. i+2*j. i=. i.4 0 1j2 2j4 3j6 +. y 0 0 1 2 2 4 3 6 The greatest common divisor divides both of its arguments x and y to produce results that have no common factor, that is, the GCD of the quotients is 1. Moreover, these quotients represent the fraction x%y in lowest form. For example: x=. 24 [ y=. 60 x;y;(x +. y);((x , y) % (x +. y)) õııÃııÃııÃıııÀ ş24ş60ş12ş2 5ş ÁııÂııÂııÂıııã lff=. , % +. Gives lowest form of fraction x;y;(x lff y);(%/x lff y);(%/x,y);(+./x lff y) õııÃııÃıııÃıııÃıııÃıÀ ş24ş60ş2 5ş0.4ş0.4ş1ş ÁııÂııÂıııÂıııÂıııÂıã Since the functions =| and =<. (tests for non-negative and for integer) produce boolean results, the function test=. (=|) +. (=<.) is a test for non-negative or integer. For example: (test=. (=|) +. (=<.)) _2 _2.4 3 3.5 1 0 1 1 The duality of or and and may be shown as follows: ((+./~&-.);(+./~&.-.);(*./~)) d=. 0 1 õıııÃıııÃıııÀ ş1 1ş0 0ş0 0ş ş1 0ş0 1ş0 1ş ÁıııÂıııÂıııã Double +: _ 0 0 Not-Or +: y is twice y. For example: +: 3 0 _26 0 _4 x +: y is the negation of x or y. For example, 0 +: 0 is 1. Since the product of the sum of two arguments equals the sum of their squares and twice their product , the following functions are equivalent: f=. + * + g=. *:@[ + +:@* + *:@] For example: x=. 7 6 3 [ y=. 6 5 3 x (f ; g ; (f=g) ; (f-:g)) y õııııııııııÃııııııııııÃıııııÃıÀ ş169 121 36ş169 121 36ş1 1 1ş1ş ÁııııııııııÂııııııııııÂıııııÂıã Since the domain of not-or is limited to zero and one, its entire behaviour can be seen in the following function tables: d=. 0 1 Domain of nor d +:/ d Table of nor 1 0 0 0 d +./ d Table of or 0 1 1 1 -. d +./ d Negation of table of or 1 0 0 0 (+:&.-."0/~d) ; (*:/~d) Nand and nor are duals under not õıııÃıııÀ ş1 1ş1 1ş ş1 0ş1 0ş ÁıııÂıııã Signum * _ 0 0 Times *y is _1 if y is negative, 0 if it is zero, 1 if it is positive. For example: *_3 0 5 3j4 is _1 0 1 0.6j0.8 More precisely, the comparison with zero is tolerant, as defined by the following expression (using t to denote the tolerance): (y%|y)*t<:|y . The fit conjunction applies to signum, as in *!.t. * denotes multiplication, defined as in elementary mathematics and extended to complex numbers as usual: t=.+.x,y [ x=.2j4 [ y=.5j3 r=.-/*/t [ i=.+/ . * t (x,:y);t;r;i;(r j. i);(x*y) õıııÃıııÃııÃııÃıııııÃıııııÀş2j4ş2 4ş_2ş26ş_2j26ş_2j26şş5j3ş5 3ş ş ş ş şÁıııÂıııÂııÂııÂıııııÂıııııã Signum is useful in effecting selections. For example: * y=. _4 0 4 _1 0 1 >:@* y 0 1 2 f=. %: f ^: * " 0 y Inverse of f, Identity, or f 16 0 2 (* y) { ;:'Yes No Maybe' Select using indexing ({) õıııııÃıııÃııÀ şMaybeşYesşNoş ÁıııııÂıııÂııã g=. <:`-:`+:@.*"0 See agenda (@.) g y _8 _1 2 The dyad * used on a list and a table illustrates the significance of agreement, as discussed in Section II B: m=. i. 3 4 [ v=. 3 2 1 m ; (v*m) ; (m*v) ; (+/ m*v) ; (v +/ . * m) õıııııııııÃııııııııııÃııııııııııÃıııııııııııÃıııııııııııÀ ş0 1 2 3ş0 3 6 9ş0 3 6 9ş16 22 28 34ş16 22 28 34ş ş4 5 6 7ş8 10 12 14ş8 10 12 14ş ş ş ş8 9 10 11ş8 9 10 11ş8 9 10 11ş ş ş ÁıııııııııÂııııııııııÂııııııııııÂıııııııııııÂıııııııııııã Length / Angle *. _ 0 0 LCM (And) *.y is a two-element list of the length and angle (in radians) of the hypotenuse of a triangle with base and altitude equal to the real and imaginary parts of the argument. For example, *. 3j4 is 5 0.927295. x*.y is the least common multiple of x and y. For boolean arguments (0 and 1) it is equivalent to and. Thus:0 0 1 1*.0 1 0 1 is 0 0 0 1 Some properties of the length / angle are illustrated in the following, including the fact that the length (i.e. magnitude) of the product of two complex numbers is the product of their lengths, and the angle of the product is the sum of their angles: ({.@*. , |) y=. 3j4 Length is magnitude 5 5 x=. 2j_6 *. x,y Polar coordinates 6.32456 _1.24905 5 0.927295 f=. */@:({."1) , +/@:(}."1) Product over first column and sum over last f *. x , y 31.6228 _0.321751 *. x * y Length and angle of product 31.6228 _0.321751 The least common multiple is the product divided by the GCD. For example: x=. 24 [ y=. 60 x +. y 12 (x * y) % x +. y 120 x *. y 120 ((*./~);(+./~&.-.)) 0 1 And and or are dual under negation õıııÃıııÀ ş0 0ş0 0ş ş0 1ş0 1ş ÁıııÂıııã Square *: _ 0 0 Not-And *: y is the square of y. x *: y is the negation of x and y. For example 0 +: 0 is 1. The inverse of the square is the square root. For example: *: ^: _1 %: *: ^: _1 (_2 _1 0 1 2) 0j1.41421 0j1 0 1 1.41421 Since the domain of nand is limited to zero and one, its entire behaviour can be seen in the following function tables: d=. 0 1 Domain of nand d *:/ d Table of nand 1 1 1 0 d *./ d Table of and 0 0 0 1 -. d *./ d 1 1 1 0 Nand, Not and, and the dual of Nor all agree, as illustrated below: (*:/~ ; -.@*./~ ; +:&.-."0/~) d õıııÃıııÃıııÀ ş1 1ş1 1ş1 1ş ş1 0ş1 0ş1 0ş ÁıııÂıııÂıııã Negate - _ 0 0 Minus -y is the negative of y. That is, it is defined as 0á-áy . Thus, -2á0 _2 is _2 0 2 . - is defined as subtraction as in elementary arithmetic, and is extended to complex numbers as usual. The function - is self-inverse, that is, -^: _1 is - . Although -2 may often be used instead of _2, it is important to understand that the former is the application of a function to the number 2, whereas the symbol _ is an indivisible part of the number representation, just as the period is an indivisible part of a number such as 8.9 . Not -. _ _ _ Less -.y is 1-y; for a boolean argument it is the complement (not); for a probability, it is the complementary probability. Items of x-.y are all of the items of x except for those that are cells of y. The function less applies to any pair of arguments. For example: (i. 9) -. 2 3 5 7 0 1 4 6 8 'abcdefghij' -. 'aeiou' bcdfghj m=. i. 4 5 m 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 m -. 5 6 7 8 9 0 1 2 3 4 10 11 12 13 14 15 16 17 18 19 b=. <\ 'abcdefg' b õıÃııÃıııÃııııÃıııııÃııııııÃıııııııÀ şaşabşabcşabcdşabcdeşabcdefşabcdefgş ÁıÂııÂıııÂııııÂıııııÂııııııÂıııııııã b -. 'abc';'abcde';'cba' õıÃııÃııııÃııııııÃıııııııÀ şaşabşabcdşabcdefşabcdefgş ÁıÂııÂııııÂııııııÂıııııııã 2 3 4 5 -. 'abcdef' 2 3 4 5 Halve -: _ _ _ Match -:y is one half of y . For example: -: i. 50 0.5 1 1.5 2 x -: y yields 1 if its arguments match: in shapes, boxing, and elements; but using tolerant comparison. See Equal (=).Matching with a tolerance t can be obtained using the phrase -: !. t . For example: -: ^:_1 +: x=. 0 1 2 3 4 5 ,.&.> (] ; -: ; +:@-: ; (%&2) ; (2: %~ ])) x õıÃıııÃıÃıııÃıııÀ ş0ş 0ş0ş 0ş 0ş ş1ş0.5ş1ş0.5ş0.5ş ş2ş 1ş2ş 1ş 1ş ş3ş1.5ş3ş1.5ş1.5ş ş4ş 2ş4ş 2ş 2ş ş5ş2.5ş5ş2.5ş2.5ş ÁıÂıııÂıÂıııÂıııã x = +: -: x 1 1 1 1 1 1 x -: +: -: x 1 Reciprocal % _ 0 0 Divided by % y is the reciprocal of y, that is, 1%y. For example, %4 is 0.25. x % y is division of x by y as defined in elementary math, except that 0%0 is 0. See McDonnell [12], and the resulting pattern in the middle column and middle row of the table below. We will illustrate the divide function by tables, using a function to generate lists symmetric about zero: sym=. i.@>:@+: - ] Symmetric integers a=. sym 3 a _3 _2 _1 0 1 2 3 |. a %/ a _1 _1.5 _3 _ 3 1.5 1 _0.666667 _1 _2 _ 2 1 0.666667 _0.333333 _0.5 _1 _ 1 0.5 0.333333 0 0 0 0 0 0 0 0.333333 0.5 1 __ _1 _0.5 _0.333333 0.666667 1 2 __ _2 _1 _0.666667 1 1.5 3 __ _3 _1.5 _1 6.2 ": |. a %/ a _1.00 _1.50 _3.00 _ 3.00 1.50 1.00 _0.67 _1.00 _2.00 _ 2.00 1.00 0.67 _0.33 _0.50 _1.00 _ 1.00 0.50 0.33 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.33 0.50 1.00 __ _1.00 _0.50 _0.33 0.67 1.00 2.00 __ _2.00 _1.00 _0.67 1.00 1.50 3.00 __ _3.00 _1.50 _1.00 The final use of the format function gives a more readable result, with a width of six spaces per column, and a uniform two digits after the decimal point.