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
#!r6rs | |
(library (generalized-set) | |
(export (rename (set!!! set!)) | |
define-getter/setter) | |
(import (rnrs) | |
(rnrs mutable-pairs) | |
(rnrs mutable-strings)) | |
;; Usage: | |
;; > (import (generalized-set)) |
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
(define (random-permutate lst) | |
(let* ([len (length lst)] | |
[i (rand len)] | |
[j (let loop ((number (rand len))) | |
(if (= number i) | |
(loop (rand len)) | |
number))] | |
[vec (list->vector lst)]) | |
(vector-swap! vec i j) | |
(vector->list vec))) |
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
(library (tagbody) | |
(export tagbody go) | |
(import (rnrs) | |
(for (tagbody utils) expand) | |
(for (srfi :8 receive) expand)) | |
(define (go tag) | |
(tag #f)) | |
(define-syntax tagbody |
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
(library (tagbody utils) | |
(export plist->alist | |
shift-left | |
unzip | |
syntax->list | |
) | |
(import (rnrs)) | |
(define (syntax->list stxobj) | |
(define (inner stx) |
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
; guile -x ".sls" -x ".ss" -x ".guile.sls" tests.scm | |
(import (rnrs) | |
(tagbody) | |
(wak trc-testing)) | |
(define-syntax inc! | |
(syntax-rules () | |
((inc! x) | |
(set! x (+ x 1))) | |
((inc! x n) |
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
(define (s:reify thunk) | |
(reset-at 'state (s:return (thunk)))) | |
(define (s:reflect m) | |
(shift-at 'state k (s:>>= m k))) | |
(define (r:reify thunk) | |
(reset-at 'reader (return (thunk)))) | |
(define (r:reflect m) |
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
@node Syntax Parameters | |
@subsection Syntax Parameters | |
Syntax parameters@footnote{Described in the paper @cite{Keeping it Clean with | |
Syntax Parameters} by Barzilay, Culpepper and Flatt.} are a mechanism for rebinding a macro | |
definition within the dynamic extent of a macro expansion. It provides | |
a convenient solution to one of the most common types of unhygienic | |
macro: those that introduce a unhygienic binding each time the macro | |
is used. Examples include a 'lambda' form with a 'return' keyword , or | |
class macros that introduce a special 'self' binding. |
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
;; general tree fold | |
(define (traverse traverser nil tree) | |
(define (left nil) | |
(traverse traverser nil (node-left tree))) | |
(define (right nil) | |
(traverse traverser nil (node-right tree))) | |
(if (empty? tree) | |
nil | |
(traverser (node-key tree) | |
(node-key value) |
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
;; bbtree-traverse : (any any (any -> any) (any -> any) any) any bbtree -> any | |
;; A general tree traversal procedure. Returns the value of applying | |
;; the traverser procedure to the current node's key, value, a | |
;; procedure to traverse the left subtree, a procedure to traverse the | |
;; right subtree, and a base value. The subtree traversal procedures | |
;; both take a base argument, and call bbtree-traverse recursively on | |
;; the appropriate subtree. It is mostly useful for implementing | |
;; other, more specific tree traversal procedures. For example, | |
;; (define (l-to-r-pre-order cons base bbtree) | |
;; (bbtree-traverse (lambda (key value left right base) |
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
@node Syntax Parameters | |
@subsection Syntax Parameters | |
Syntax parameters@footnote{Described in the paper @cite{Keeping it Clean with | |
Syntax Parameters} by Barzilay, Culpepper and Flatt.} are a mechanism for rebinding a macro | |
definition within the dynamic extent of a macro expansion. It provides | |
a convenient solution to one of the most common types of unhygienic | |
macro: those that introduce a unhygienic binding each time the macro | |
is used. Examples include a 'lambda' form with a 'return' keyword , or | |
class macros that introduce a special 'self' binding. |