Last active
April 10, 2019 04:44
-
-
Save rummik/9726111 to your computer and use it in GitHub Desktop.
Random Dimond code examples
This file contains 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
#** | |
* For statement definition | |
* | |
* @example | |
* for { $i=0; $i<20; $i++ } { | |
* ... | |
* } | |
*# | |
define { Function, Function } 'for' { | |
{ $expression, $body } = $$~arguments | |
{ $initial, $condition, $each } = $expression | |
$expression~scope = $body~scope = $$~stack[-2]~scope | |
$initial() | |
{ | |
unless $condition() { | |
$body() | |
$each() | |
$self() | |
} | |
} | |
} |
This file contains 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
#** | |
* If statement | |
* | |
* @example | |
* if $condition { | |
* ... | |
* } | |
*# | |
define { ???, Function } 'if' { | |
{ $condition, $body } = $$~arguments | |
$condition && $body() | |
} |
This file contains 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
#** | |
* Unless statement | |
* | |
* @example | |
* unless $condition { | |
* ... | |
* } | |
*# | |
define { ???, Function } 'unless' { | |
{ $condition, $body } = $$~arguments | |
$condition || $body() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
possible way to define lambda parameters
or with named parameters