]y=. a. {~ (a. i. 'A') + i. 2 3 4 ABCD EFGH IJKL MNOP QRST UVWX ,y ABCDEFGHIJKLMNOPQRSTUVWX ravel y ABCDEFGHIJKL MNOPQRSTUVWX Do ". 1 If y is a valid sentence, then ".y executes it. If a=.".y, then a is assigned a noun resulting from the execution; if the result of execution is not a noun, then a is assigned an empty vector. However, any assignments made within the execution are valid. For example: s=. '5 * a=. 3 + i. 6' ". s 15 20 25 30 35 40 a 3 4 5 6 7 8 do=. ". do s 15 20 25 30 35 40 t=. '3 % 5' do t 0.6 do |. t 1.66667 $ do '' 0 ]program=. 'a=. 2^3' ,: '5*a' a=. 2^3 5*a do program 8 40 $ do 'sum=. +/' 0 sum 1 2 3 4 10 Default Format ": _ 1 1 Format ": y is equal to x ": y, where x is chosen to provide a minimum of one space between columns. Default output is identical to this monadic case. For example: ]text=. ": i. 2 50 1 2 3 45 6 7 8 9 $ text2 9 3 + text|domain error| 3 +text '*#' ,"0 1 text*0 1 2 3 4#5 6 7 8 9 ": 'abcd'abcd $ ": ''0 x ": y produces a literal representation of y in a format specified by x. Each element e of x controls the representation of the corresponding element of y as follows:w=. <.|e specifies th e total width allocated; if this space is inadequate, the entire space is filled with asterisks. If w is zero, enough space is allocated.d=.<.10*(|e)-w specifies the num-ber of digits following the decimal point (itself included only if d is not zero).Any negative sign is placed just before the leading digit.If e>:0, the result is right-justified in the space w.If e<0, the result is put in exponential form (with one digit before the decimal point) and is left-justified except for two fixed spac es allowed on the left (including one for a possible negative sign). For example: n ; 6.2 ": n=. % i. 2 4 õýýýýýýýýýýýýýýýýýýýýýýýýýýýýÃýýýýýýýýýýýýýýýýýýýýýýýýÀ þ _ 1 0.5 0.3333333þ _ 1.00 0.50 0.33þ þ0.25 0.2 0.1666667 0.1428571þ 0.25 0.20 0.17 0.14þ ÁýýýýýýýýýýýýýýýýýýýýýýýýýýýýÂýýýýýýýýýýýýýýýýýýýýýýýýã (7.2 ": -n) ; (3.2 ": n) õýýýýýýýýýýýýýýýýýýýýýýýýýýýýÃýýýýýýýýýýýýÀ þ __ _1.00 _0.50 _0.33þ _*********þ þ _0.25 _0.20 _0.17 _0.14þ************þ ÁýýýýýýýýýýýýýýýýýýýýýýýýýýýýÂýýýýýýýýýýýýã The fit conjunction specifies the number of digits for floating-point numbers. For example: ":!.4 (5%3) 1.667 TIE m`n m`v u`n u`v In English, a gerund is a noun that carries the force of a verb, as does the noun cooking in the art of cooking. The tie applies to two verbs to produce a gerund. Gerunds are commonly used with insert (/) and with agenda (@.): ]g=. +`* õýÃýÀ þ+þ*þ ÁýÂýã (g/1 2 3 4 5) ; (1+2*3+4*5) õýýÃýýÀ þ47þ47þ ÁýýÂýýã More generally, tie produces gerunds as follows: u`v is au,av, where au and av are the (boxed noun) atomic representations of u and v. Moreover, m`n is m,n and m`v is m,av and u`n is au,n. See Bernecky and Hui [13]. Gerunds may also be produced directly by boxing. Thus: ]h=. '+' ; '*' õýÃýÀ þ+þ*þ ÁýÂýã h/1 2 3 4 5 47 The atomic representation of a noun (used so as to distinguish a noun such as '+' from the verb +) is given by the following function: (ar=. [: < (,'0')"_ ; ]) '+' õýýýýýÀ þõýÃýÀþ þþ0þ+þþ þÁýÂýãþ Áýýýýýã *`(ar '+') õýÃýýýýýÀ þ*þõýÃýÀþ þ þþ0þ+þþ þ þÁýÂýãþ ÁýÂýýýýýã EVOKE GERUND m `: n _ _ _ This adverb is defined for three cases:m `: 0 Append Appends the results of the individual verbs; the ranks are the maxima over their ranks. Equivalent to m/.m `: 3 Insert Inserts verbs between items. Equivalent to m/m `: 6 Train Result is the train of individual verbs. Equivalent to m\ For example: <+:`-:`% `: 0 a=. 1 2 3 4 5 õýýýýýýýýýýýýýýýýýýýýýýýýýýÀ þ 2 4 6 8 10þ þ0.5 1 1.5 2 2.5þ þ 1 0.5 0.3333333 0.25 0.2þ Áýýýýýýýýýýýýýýýýýýýýýýýýýýã (+ b.0);( %. b.0);(+`%.`:0 b.0) õýýýýýÃýýýýýÃýýýýýÀ þ_ 0 0þ2 _ 2þ_ _ _þ ÁýýýýýÂýýýýýÂýýýýýã (+`* `:3 a);(+`*/a);(1+2*3+4*5) õýýÃýýÃýýÀ þ47þ47þ47þ ÁýýÂýýÂýýã (+`*`- `: 6 a) ; (+`*`- \ a) õýýýýýýýýýýýýýýýýÃýýýýýýýýýýýýýýýýÀ þ_1 _4 _9 _16 _25þ_1 _4 _9 _16 _25þ ÁýýýýýýýýýýýýýýýýÂýýýýýýýýýýýýýýýýã ATOP u @ v mv lv rv u@v y is u v y. For example, +:@- 7 is _14 (double the negation). Moreover, the monadic uses of u@v and u&v are equivalent . x u@v y is u x v y. For example,3 +:@- 7 is _8 (double the difference). Because adverbs and conjunctions are (as stated more precisely in Section II E) executed before verbs, phrases involving them are commonly used in trains without parentheses. For example: mean=. +/ % # mean 1 2 3 4 2.5 f=. +:@*: +/ -:@%: Addition table of doubled square and f 1 2 3 4 halved square root 2.5 2.70711 2.86603 3 8.5 8.70711 8.86603 9 18.5 18.7071 18.866 19 32.5 32.7071 32.866 33 Because a conjunction applies to the entity immediately to its right, expressions to the right of conjunctions commonly require parenthesization. For example: g=. *:@(+/) h=. *:@+/ g 1 2 3 4 100 h 1 2 3 4 6770404 k=. *:@+ k/1 2 3 4 6770404 Compare the behaviour of @ with that of @:. They differ only in the ranks of the verbs that they produce. AGENDA m @. n m @. v mv lv rv m@.n is a verb defined by the gerund m with an agenda specified by n; that is, the verb represented by the train selected from m by the indices n. If n is boxed, the train is parenthesized accordingly. The case m@.v uses the result of the verb v to perform the selection. For example: dorh=. +: ` -: @. (]>9:) Double or halve (Case statement) dorh " 0 primes=. 2 3 5 7 11 13 17 19 4 6 10 14 5.5 6.5 8.5 9.5 _:`%:`*: @. * "0 a=. 2 1 0 _1 _2 1.41421 1 _ 1 4 g=. +`-`* [. x=. 1 2 3 [ y=. 6 5 4 (x g@.2: y) 6 10 12 (] * <:) y=. 5 4 3 2 1 0 Basis of factorial 20 12 6 2 0 0 1:`(] * <:) @. (1: < ]) "0 y Case statement 20 12 6 2 1 1 1:`(] * $:@<:)@.(1: < ])"0 y Self-reference for recursion 120 24 6 2 1 1 +`-`*`% @. (1 0 3;2 0) (- + %) (* +) 3 +`-`*`% @. (1 0 3;2 0) 4 _12.8125 all=. b <@(<;.1) ] b=. 1:,.[:#:[:i. 2&^@<:@# all 0 1 2 õýýýýýýýÃýýýýýýýÃýýýýýýýÃýýýýýýýÀ þõýýýýýÀþõýýýÃýÀþõýÃýýýÀþõýÃýÃýÀþ þþ0 1 2þþþ0 1þ2þþþ0þ1 2þþþ0þ1þ2þþ þÁýýýýýãþÁýýýÂýãþÁýÂýýýãþÁýÂýÂýãþ ÁýýýýýýýÂýýýýýýýÂýýýýýýýÂýýýýýýýã all +`-`* õýýýýýýýýýÃýýýýýýýýýýýÃýýýýýýýýýýýÃýýýýýýýýýýýýýÀ þõýýýýýýýÀþõýýýýýÃýýýÀþõýýýÃýýýýýÀþõýýýÃýýýÃýýýÀþ þþõýÃýÃýÀþþþõýÃýÀþõýÀþþþõýÀþõýÃýÀþþþõýÀþõýÀþõýÀþþ þþþ+þ-þ*þþþþþ+þ-þþþ*þþþþþ+þþþ-þ*þþþþþ+þþþ-þþþ*þþþ þþÁýÂýÂýãþþþÁýÂýãþÁýãþþþÁýãþÁýÂýãþþþÁýãþÁýãþÁýãþþ þÁýýýýýýýãþÁýýýýýÂýýýãþÁýýýÂýýýýýãþÁýýýÂýýýÂýýýãþ ÁýýýýýýýýýÂýýýýýýýýýýýÂýýýýýýýýýýýÂýýýýýýýýýýýýýã AT u @: v _ _ _ @: is equivalent to @ except that ranks are infinite. For example: x=. 1 2 3 4 y=. 7 5 3 2 x */ @: + y Applies product over sums to the entire lists 2016 x */ @ + y Applies product over sums to each item of the list 8 7 6 6 + b. 0 _ 0 0 */ @: + b. 0 _ _ _ */ @ + b. 0 _ 0 0 BOND m & v u & n _ (see next topic) m&v y is defined as m v y; in other words, the left argument m is bonded with the dyad v to produce a monadic function. For example: 10&^. 2 3 10 100 200 0.30103 0.477121 1 2 2.30103 sine=. 1&o. sine o. 0 0.25 0.5 1.5 2 0 0.707107 1 _1 0 Similarly, u&n y is defined as y u n; in other words, as the dyad u provided with the right argument n to produce a monadic function (that is, a function whose dyadic case has an empty domain). For example: ^&3 (1 2 3 4 5) 1 8 27 64 125 ^&2 3"0 (1 2 3 4 5) 1 1 4 8 9 27 16 64 25 125 Use of the bond conjunction is often called Currying in honour of Haskell Curry. COMPOSE u & v mv lv rv (see previous) u&v y is u v y. Thus, +:&- 7 is _14 (double the negation). Moreover, the monadic uses of u&v and u@v are equivalent . x u&v y is (v x) u (v y).For example, 3 +&! 4 is 30, the sum of factorials. The monadic case is equivalent to the composition used in mathematics, but the dyadic case opens up other possibilities. For example: 3 +&^. 4 Sum of natural logarithms 2.48491 ^ 3 +&^. 4 Multiplication using natural logs 12 3 +&(10&^.) 4 Sum of base ten logarithms 1.07918 10 ^ 3 +&(10&^.) 4 Multiplication using base ten logs 12 3 +&.^. 4 See the related conjunction under (&.). 12 3 +&.(10&^.) 4 12 Compare the behaviour of & with that of &:. They differ only in the ranks of the verbs that they produce. UNDER u &. v mv mv mv The verb u &.v is equivalent to the composition u & v except that the verb obverse to v is applied to the result for each cell. The obverse is normally the inverse, as discussed more fully under the power conjunction ^: . For example: 3 + &. ^. 4 Inverse of natural log is the exponential 12 (^. ^: _1) 3 + & ^. 4 12 ( An adverb (<|. &. > b),(<|. each b) Reversal under open õýýýýýýýýýýýýýýýýýýýýýÃýýýýýýýýýýýýýýýýýýýýýÀ þõýýýýýÃýýýýýýýÃýýýýýÀþõýýýýýÃýýýýýýýÃýýýýýÀþ þþ3 2 1þ7 5 3 2þedcbaþþþ3 2 1þ7 5 3 2þedcbaþþ þÁýýýýýÂýýýýýýýÂýýýýýãþÁýýýýýÂýýýýýýýÂýýýýýãþ ÁýýýýýýýýýýýýýýýýýýýýýÂýýýýýýýýýýýýýýýýýýýýýã In mathematics, certain cases of under are called dual or, dual with respect to: f=. +. &. -. Dual with respect to boolean negation f"0/~ d=. 0 1 0 0 0 1 D=. (&. -.) ("0) The adverb dual with respect to negation (+.D/~d);(*./~d);(=D/~d);(~:/~d) õýýýÃýýýÃýýýÃýýýÀ þ0 0þ0 0þ0 1þ0 1þ þ0 1þ0 1þ1 0þ1 0þ ÁýýýÂýýýÂýýýÂýýýã DWL=. (&. ^.) ("0) Dual with respect to natural logarithm DAN=. (&. -) ("0) Dual with respect to arithmetic negation (3 + DWL 4),(3*4),(3 <. DAN 4) , (3 >. 4) 12 12 4 4 Min and max are duals with respect to arithmetic negation APPOSE u &: v _ _ _ &: is equivalent to & except that the ranks of the resulting function are infinite; the relation is similar to that between @: and @ . For example: a=. 'abcd' ; 'efgh' b=. 'ABCD' ; 'EFGH' a ,&:> b abcd efgh ABCD EFGH a ,&> b abcdABCD efghEFGH > b. 0 0 0 0 , & > b. 0 0 0 0 , &: > b. 0 _ _ _ Roll ? _ 0 0 Deal ? y yields a uniform random selection from the population i. y. x ? y is a list of x items randomly chosen without repetition from i.y. For example: ?6 0 ?6 6 6 6 6 6 6 6 4 2 3 1 0 4 4 5 6 ? 6 A random permutation 3 2 0 4 1 5 mean=. +/ % # mean ? 1000 # 6 2.503 mean ? 1000 # 6 2.522 m=. ? 4 4 $ 9 A random matrix for experimentation m 7 4 6 1 2 0 3 7 8 5 5 5 8 6 1 4 -/ . * m _93 f=. ?@$ % ] - 1: <3 6 f 9 Random 3 by 6 table in range zero to one with resolution 9