>>  <<  Usr  Pri  JfC  LJ  Phr  Dic  Rel  Voc  !:  Help  Dictionary

Explicit Definition m : n  _ _ _  

m is an integer producing the following cases:
0 : n   noun
1 : n adverb
2 : n conjunction
3 : n verb
4 : n dyad-only verb
13 : n tacit verb if possible, otherwise equivalent to 3 : n
n is usually 0, indicating a script (Section II H) taken from the keyboard, or a script represented as a literal list s , a boxed list b=: <;._2 s , or a literal table t=: ];._2 s . Thus:

f=: 3 : 0
a=: 2+b=. y ^ 2

   a=: b=: 19
   f 3

   a,b           NB. Only the globally assigned name is changed.
11 19
As illustrated by the foregoing:

1.    The definitions of the monadic and dyadic cases produced by 3 : 0 are separated by a colon on a line by itself; if none occurs, the domain of the dyadic case is empty.
2. The explicit result is the result of the last non-test block sentence executed; that result must be a noun in the 3 : and 4 : cases. See Control Structures for the definition of a block.
3. A name assigned by the copula =. is made local; values assigned to it have no effect on the use of the same name without the entity defined or within other entities invoked by it. A name assigned by =: is global, except that global assignment to a local name is not permitted. Locative assignment (using either =: or =.) is always global.
4. The arguments to a definition are initialized by =. . The effects for a dyadic verb are as follows:
  f=: 4 : 0
   x=. (left   argument)
   y=. (right argument)
   (rest of verb)
5. The names x and y denote the left and right arguments. In defining a conjunction it may be necessary to refer to its left and right arguments (using u and v) as well as to the arguments of the resulting verb (x and y); likewise, an adverb may refer to its left argument (using u) as well as to the arguments of the resulting verb (x and y). The use of m instead of u restricts the corresponding argument to being a noun, as does the use of n instead of v . For example:
   conj=: 2 : '(u y)+ (v y)'
   mc=: 2 : 0
(u y)+(v y)

   dc=: 2 : 0                 Dyadic case
(u y)+(v x)

   (!conj% 2 4 5);(!mc% 2 4 5);(1 2 3 !dc% 2 4 5)
|2.5 24.25 120.2|2.5 24.25 120.2|3 24.5 120.333|
Control Structures. The sequence of execution of an explicit definition may be determined by control words such as if. do. else. end. and while. . For example, a function to find the root of a function f from a two-element list that brackets the root may be written and executed as follows:
   root=: 3 : 'm=.+/%#while.~:/y do.if.~:/*f b=.(m,{.)y do.y=.b else.y=.(m,{:)y end.end.m y'

   f=: 2 - *:
   b=: 1 10
   root b
Such a definition may also be written on multiple lines and made more readable as follows:
root=: 3 : 0
 m=. +/ % #
 while. ~:/y do. 
  if. ~:/*f b=. (m,{.) y do. 
   y=. b 
   y=. (m,{:) y
 m y

As illustrated by the foregoing, the word if. and a matching end. mark the beginning and end of a control structure, as do while. and a matching end.; such structures may be nested as is the if. structure within the while. structure. The words do. and else. break the if. structure into three simple blocks, each comprising a sentence, whereas the do. in the while. structure breaks it into two blocks, the first being a simple sentence, and the second being itself an if. control structure. Therefore, control words provide a form of punctuation.

Additional explanations and examples can be found in the Control Structures section.

>>  <<  Usr  Pri  JfC  LJ  Phr  Dic  Rel  Voc  !:  Help  Dictionary