Created
August 10, 2012 07:15
-
-
Save Idorobots/3312154 to your computer and use it in GitHub Desktop.
ASM code sample
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
#; ASM code sample** | |
#; Extend the language however you please. | |
(syntax (Ternary < Expression (: "\\?") Expression (: ":") Expression) | |
`($(car Ternary) | |
($(ternary-to-if (caadr Ternary))))) | |
#; Use the whole language to your advantage. | |
(function (ternary-to-if t) | |
`(if $(car t) | |
$(cadr t) | |
$(caddr t))) | |
#; Interaction with the rest of the grammar is well-defined. | |
#; No more hard to find bugs! | |
(syntax (Expression < (/ Quote Tuple Vector String Ternary Atom)) | |
#; It's that simple! | |
(function (abs x) | |
(> 0 x) ? (- x) : x ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment