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
(use srfi-1) | |
(define (assoc-get getter key alist =) | |
(cond | |
((assoc key alist =) => getter) | |
(else #f))) | |
(define (assq-get g k l) (assoc-get g k l eq?)) | |
(define (assv-get g k l) (assoc-get g k l eqv?)) |
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 prefix | |
(syntax-rules () | |
((_ head body ...) | |
(begin (head . 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
(define (compose . fns) | |
(if (null? fns) | |
(lambda args (apply values args)) | |
(let ( [fn1 (car fns)] [fns (cdr fns)] ) | |
(lambda args | |
(call-with-values | |
(lambda () (apply fn1 args)) | |
(apply compose fns)))))) |
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
(use srfi-1 srfi-26) | |
(define-syntax (arrow form rename compare) | |
(let ( [knil (cadr form)] [preds (cddr form)] ) | |
(fold | |
(lambda (func tail) | |
`(,(rename 'call-with-values) (,(rename 'cut) ,@tail) ,func)) | |
`(,rename 'values) ,knil) | |
preds))) |
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
void qsorti(int[] a, size_t size) { | |
int comapre(const void *ap, const void *bp) { | |
return *(int*)ap - *(int*)bp; | |
} | |
qsort(a, size, sizeof(int), comapre) | |
} |
NewerOlder