Monadic: Difference between revisions

From NARS2000
Jump to navigationJump to search
No edit summary
No edit summary
Line 10: Line 10:
<apll>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dealcard 7<br/>
<apll>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dealcard 7<br/>
33 1 3 4 42 40 21<br/></apll>
33 1 3 4 42 40 21<br/></apll>
To make this related to a deck of cards you'd have to relate the numbers to the rank and suit.


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

Revision as of 03:31, 28 February 2013

A function is monadic if it accepts an argument 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 in the range of 1 to 52. Or to visualize:

      dealcard 7
33 1 3 4 42 40 21
To make this related to a deck of cards you'd have to relate the numbers to the rank and suit.

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 ⎕DL function delays execution for an amount of time indicated by the argument.

See Also