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
(require 'memory-stats) | |
(setq memory-usage-update-interval 5) | |
(setq memory-usage-format "Mem: %R Free: %F Swap: %S") | |
(memory-usage-start) |
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
(require 'cpu-stats) | |
(setq cpu-usage-update-interval 1) | |
(setq cpu-usage-format "Average: %A CPU0: %C0 CPU1: %C1") | |
(cpu-usage-start) |
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
(grammar ((JValue < (/ String Number JObject JArray JTrue JFalse JNull))) | |
((JObject < (: "\\{") (? JPair (* (:",") JPair)) (:"\\}")) | |
`($(car JObject) | |
($(cons 'scope (cadr JObject))))) | |
((JPair < String (: ":") JValue) | |
`($(car JPair) | |
((var $(str->symbol (caadr JPair)) $(cadadr JPair))))) | |
((JArray < (:"\\[") (? JValue (* (:",") JValue)) (:"\\]")) | |
`($(car JArray) | |
($(vectorof (cadr JArray))))) |
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
(var json { "number": 1234.567, | |
"string": "abcd", | |
"object": { "member0": "value", | |
"member1": "value" }, | |
"boolean": true, | |
"null": null }) | |
(set! (json number) 9876.543) |
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
sequence: (A B C ...) => A B C ... | |
ordered choice: (/ A B C ...) => A / B / C / ... | |
optional branch: (? ...) => (...)? | |
zero or more: (* ...) => (...)* | |
one or more: (+ ...) => (...)+ | |
not: (! ...) => !(...) | |
and (lookahead): (& ...) => &(...) | |
drop node: (: ...) - Drops a node from the parse tree. | |
concat captures: (~ ...) - Concatenates captures. |
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
(syntax (Lambda < List (: "->") Expression) | |
`($(car Lambda) | |
((lambda $(caadr Lambda) $(cadadr Lambda))))) | |
(syntax (Expression < (/ Lambda String List Atom))) | |
(Expression "(map (x) -> (* x x) | |
(list 1 2 3 4 5))") |
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
(grammar ((Expression < (/ String List Atom))) | |
((String <- (:"\"") "[^\"]*" (: "\""))) | |
((List < (: "\\(") (* Expression) (: "\\)")) | |
`($(car List) | |
$(cdr List))) | |
((Atom <- (/ Number Symbol))) | |
((Number <- "[+\\-]?[0-9]+(\\.[0-9]*)?") | |
`($(car Number) | |
($(str->num (caadr Number))))) | |
((Symbol <- (! Number) "[^\\(\\)\"';\\s]+") |
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
(var bus-size 16) | |
(var A (make-bus bus-size)) | |
(var B (make-bus bus-size)) | |
(var c (make-wire)) | |
(probe 'Carry c) | |
(var S (make-bus bus-size)) | |
(ripple-carry-adder A B S c) | |
(set-bus-value! A '(1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1)) |
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
(var (a b s c) (times 4 make-wire)) | |
(probe 'sum s) | |
(probe 'carry c) | |
(half-adder a b s c) | |
(set-signal! a 1) | |
(set-signal! b 1) | |
(propagate) | |
;; 0ns - sum: new value = 0 | |
;; 0ns - carry: new value = 0 |
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) |