Dyadic: Difference between revisions

From NARS2000
Jump to navigationJump to search
No edit summary
(explain & add cat)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
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:<br/>
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:<br/>
<apll>&nbsp;&nbsp;&nbsp;&nbsp;∇ k ← count deal cards;C<br/>
<apll>&nbsp;&nbsp;&nbsp;&nbsp;∇ k ← count deal cards;c<br/>
[1]&nbsp;&nbsp;&nbsp;c ← count<br/>
[1]&nbsp;&nbsp;&nbsp;c ← count<br/>
[2]&nbsp;&nbsp;&nbsp;k ←''<br/>
[2]&nbsp;&nbsp;&nbsp;k ←''<br/>
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)
<br/><hr/>
{{Article footer|0|NO}}
[[Category:Definitions]]
[[Category:Dyadic operators]]

Latest revision as of 17:24, 13 October 2019

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




See Also
System Commands System Variables and Functions Operators


Keyboard
Alt+Shift
Alt ¨ ¯ < > × ÷
Shift ~ ! @ # $ % ^ & * ( ) _ +
Key ` 1 2 3 4 5 6 7 8 9 0 - =
Alt+Shift
Alt ? § π
Shift Q W E R T Y U I O P { } |
Key q w e r t y u i o p [ ] \
Alt+Shift
Alt
Shift A S D F G H J K L : "
Key a s d f g h j k l ; '
Alt+Shift χ
Alt
Shift Z X C V B N M < > ?
Key z x c v b n m , . /
NARS 2000 Lang
Tool
Bar
+ - × ÷ * ! ? |
< = >
~ § π .. ,
/ \ ¨ .
_ ¯
Second Row i j k i j k l g p r v x