>>  <<  Ndx  Usr  Pri  Phr  Dic  Rel  Voc  !:  wd  Help  Dictionary

21. Gerund and Agenda

In English, a gerund is a noun that carries the force of a verb, as does the noun cooking in the phrase the art of cooking; and agenda is a list of items for action. The tie conjunction ` applies to two verbs to form a gerund, from which elements can be chosen for execution. Thus, if the agenda conjunction @. is applied to a gerund, its verb right argument provides the results that choose the elements. For example:
   g=: +`^
   a=:<
   2 a 3
1
  
   2 [email protected] 3
8

   3 [email protected] 2
5

   +:`-:`*:`%: @. (4&|@<.)"0 i. 10
0 0.5 4 1.73205 8 2.5 36 2.64575 16 4.5
The verb produced by [email protected] is often called a case or case statement, since it selects one of the "cases" of the gerund for execution.

The insert adverb / applies to a gerund in a manner analogous to its application to a verb. For example:
   c=:3 [ x=: 4 [ power=: _1
   g/ c,x,power
3.25

   3+x^_1
3.25
The elements of the gerund are repeated as required. For example:
   +`*/1,x,3,x,3,x,1
125
The last sentence above corresponds to Horner's efficient evaluation of the polynomial with coefficients 1 3 3 1 and argument x .

Exercises

21.1   Define a function f such that (x=: 4) f c=: 1 3 3 1 yields the result used as the argument to +`*/ in Horner's method.

Answer: f=: }.@,@,.




>>  <<  Ndx  Usr  Pri  Phr  Dic  Rel  Voc  !:  wd  Help  Dictionary