Monadic: Difference between revisions

From NARS2000
Jump to navigationJump to search
(Created page with "A function is '''niladic''' if it does not accept any arguments. For example: <code>'''<big>    ∇ z{:=}dealcard m<br/> [1]    z←m...")
 
No edit summary
Line 1: Line 1:
A function is '''niladic''' if it does not accept any arguments.  For example:
A function is '''monadic''' if it accepts a single arguments to the right of the function.  For example:


<code>'''<big>&nbsp;&nbsp;&nbsp;&nbsp;∇ z{:=}dealcard m<br/>
<code>'''<big>&nbsp;&nbsp;&nbsp;&nbsp;∇ z{:=}dealcard m<br/>
Line 8: Line 8:
: shuffle {:=} dealcard 7
: shuffle {:=} dealcard 7
Would set '''shuffle''' to the value of an array of 7 entries from the range of 1 to 52.
Would set '''shuffle''' to the value of an array of 7 entries from the range of 1 to 52.
An 'argument' can be an array or string or whatever the function is willing to accept.


Some System functions are monadic in that you may present them one argument, and it may return a value. The [[System Function FPC|{quad}FPC]] function returns the number of digits of precision for arithmetic calculations, and you can set it to the number of digits you want.
Some System functions are monadic in that you may present them one argument, and it may return a value. The [[System Function FPC|{quad}FPC]] function returns the number of digits of precision for arithmetic calculations, and you can set it to the number of digits you want.

Revision as of 02:15, 28 February 2013

A function is monadic if it accepts a single arguments to the right of the function. For example:

    ∇ z←dealcard m
[1]    z←m ? 52
    ∇

In this case, the function would return a shuffle of m cards from a deck of 52. So a statement of

shuffle ← dealcard 7

Would set shuffle to the value of an array of 7 entries from the range of 1 to 52.

An 'argument' can be an array or string or whatever the function is willing to accept.

Some System functions are monadic in that you may present them one argument, and it may return a value. The ⎕FPC function returns the number of digits of precision for arithmetic calculations, and you can set it to the number of digits you want.

See Also