Created
May 14, 2015 06:49
-
-
Save tommyettinger/0a37fececcc2ae39e62c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1 | |
| stack: [1] //data, integer 1 | |
| 1 + | |
| stack: [(+ 1 _)] //curried function that will await an argument and add 1 to it | |
| 1 + 2 | |
| stack: [3] //argument has been supplied to an awaiting function, function is evaluated | |
| //with full set of args | |
| 1 + 2 * | |
| stack: [(* 3 _)] //another curried function that will await an argument and multiply it by 3 | |
| 1 + 2 * [# | |
| stack: [(* 3 _) (assoc-domain _&)] //a grouping starter is on the stack, and will not supply anything to | |
| //awaiting functions until it reaches its grouping ender. this grouping, | |
| //delimited by [# and #] , is specifically an associative domain, | |
| //treating all elements inside as potential values for a contract. | |
| 1 + 2 * [# 1 | |
| stack: [(* 3 _) (assoc-domain 1 _&)] //the grouping is still awaiting its ender. it has been supplied 1, and | |
| //stores it in the elements of the grouping. | |
| 1 + 2 * [# 1 5 | |
| stack: [(* 3 _) (assoc-domain 1 5 _&)] //the grouping is still awaiting its ender. it has been supplied 1 and 5, | |
| //and stores each sequentially in the elements of the grouping. | |
| 1 + 2 * [# 1 5 #] | |
| stack: [(* 3 _) (assoc-domain 1 5)] //the grouping has been supplied its ender. it evaluates to an associative | |
| //domain containing 1 and 5. | |
| stack: [(* 3 (assoc-domain 1 5))] //now that the grouping evaluates, it is supplied to awaiting functions on | |
| //the stack. | |
| stack: [(assoc-domain 3 15)] //multiplication implicitly maps scalar arguments over collection arguments, | |
| //keeping the type of the argument. each element of the domain is multiplied by 3. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment