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
#!chezscheme | |
(library (chez-library-extras) | |
(export reimport load-internals) | |
(import (chezscheme)) | |
(define (loaded? libspec) | |
(let ([name (extract-library-name libspec)]) | |
(exists (lambda (builtin) | |
(equal? name builtin)) |
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
;;; | |
;;; Usage: | |
;;; | |
;;; ($"some normal text: $with $identifiers substituted in by the $dollar-sign") | |
;;; ($"You can also $(embed full expressions)") | |
;;; ($"Because scheme has $very-inclusive-identifier.rules, $(this) is the same as $this") | |
;;; ($"However, if you have $(multiple items) inside the parentheticals, $multiple is called with $item as the argument") | |
;;; ($"A zero argument $((function)) will be called like that") | |
;;; ($"Yes, this means $(funcion call) and $((function call)) are the same") |
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 (returning!) | |
(export set! set-car! set-cdr! vector-set! string-set! | |
hashtable-set! hashtable-update! hashtable-delete! hashtable-clear! | |
bytevector-copy! bytevector-fill! | |
bytevector-s8-set! bytevector-u8-set! | |
bytevector-s16-native-set! bytevector-s16-set! bytevector-u16-native-set! bytevector-u16-set! | |
bytevector-s32-native-set! bytevector-s32-set! bytevector-u32-native-set! bytevector-u32-set! | |
bytevector-s64-native-set! bytevector-s64-set! bytevector-u64-native-set! bytevector-u64-set!) | |
(import (prefix (rnrs) r6rs:) | |
(prefix (rnrs mutable-pairs) r6rs:) |
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
;;; | |
;;; This acts like a letrec*, with the ability to bind multiple values and destructure lists and vectors | |
;;; | |
;;; usage: | |
;;; | |
;;; (let+ ((a 1) | |
;;; (b (+ a 1)) | |
;;; ((values c d) (values (+ a b) (* a b))) | |
;;; ((vector e f g h) (vector a b c d)) |
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 (documentation) | |
(export define/document define-syntax/document | |
document describe) | |
(import (rnrs)) | |
(define doc-list '()) | |
(define (document thing description) | |
(set! doc-list (cons (cons thing (syntax->datum description)) doc-list))) |
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
#!chezscheme | |
(library (future) | |
(export spawn sync let-futures) | |
(import (chezscheme)) | |
(define-record-type future | |
(fields (immutable lock) | |
(mutable completion) | |
(mutable result)) |
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 iota | |
(fn ((count :: integer? exact? nonnegative?) | |
(start :: number? = 0) | |
(step :: number? = 1)) | |
(if (zero? count) | |
'() | |
(cons start | |
(iota (- count 1) (+ start step) step))))) | |
(define member |
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-syntax param-args | |
(syntax-rules () | |
[(_ arg-list (opt param) ...) | |
(let loop ([args arg-list]) | |
(if (null? args) | |
'() | |
(case (car args) | |
[(opt) (if (null? (cdr args)) | |
(errorf 'param-args "Missing required argument for ~a" opt)) | |
(param (cadr args)) |
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 (html) | |
(export html display-html) | |
(import (rnrs)) | |
(define short-tags (make-enumeration '(br img link meta))) | |
(define (short-tag? t) | |
(enum-set-member? t short-tags)) | |
(define (->string obj) |
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 (curry) | |
(export define-curried lambda-curried) | |
(import (rnrs)) | |
(define-syntax lambda-curried | |
(lambda (x) | |
(syntax-case x () | |
[(_ () b b* ...) #'(lambda () b b* ...)] | |
[(_ arg* b b* ...) (identifier? #'arg*) #'(lambda arg* b b* ...)] | |
[(_ (arg* ...) b b* ...) |
NewerOlder