Dyadic: Difference between revisions

From NARS2000
Jump to navigationJump to search
No edit summary
No edit summary
Line 19: Line 19:
&nbsp;23 25 43 21 15 52 14<br/></apll>
&nbsp;23 25 43 21 15 52 14<br/></apll>


Some system functions are dyadic,
The numbers generated would have to be related to a rank and suit to display a particular card.
 
Some system functions are dyadic, in that you may present them one argument on each side of the function name, and it may return a value. The [[System Function FMT|{quad}FMT]] function provides specialized formatting when used as a dyadic function.
 
== See Also==
* [[niladic]] (accepts no arguments)
* [[monadic]] (accepts one argument)
* [[dyadic]] (accepts two arguments)
* [[System Functions]]

Revision as of 22:10, 27 February 2013

A dyadic function is one that takes an argument on the left and right of the function. Here is an example of a dyadic function named deal to deal hands of cards:
    ∇ k ← count deal cards;C
[1]   c ← count
[2]   k ←''
[3]   Q:
[4]   k ← k, cards ? 52
[5]   c ← c-1
[6]   →(c>0)/Q
[7]   k←count cards ⍴ k
    ∇
So an execution of this function to deal 6 hands of 7 cards could produce the following:
      6 deal 7
 28  1  8 24 32 47 27
 38 46  1 43  3 40  7
 47 28 26  7 39  2 37
 36 12 48 46 47 31 13
 24 52 13 25 20 30 47
 23 25 43 21 15 52 14

The numbers generated would have to be related to a rank and suit to display a particular card.

Some system functions are dyadic, in that you may present them one argument on each side of the function name, and it may return a value. The ⎕FMT function provides specialized formatting when used as a dyadic function.

See Also