個人用のSchemeの数に関するまとめ.
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) | |
} |
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
(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
(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
(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 pandoric-let | |
(syntax-rules () | |
((_ ((var val) ...) body ... retval) | |
(let ((this #f) (var val) ...) | |
(set! this retval) | |
body ... | |
(lambda args | |
(case (car args) | |
((__pandoric-set) | |
(case (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
:set nocompatible | |
:set hlsearch | |
:set smartindent | |
:set autoindent | |
:set expandtab | |
:set smarttab | |
:set tabstop=2 | |
:set shiftwidth=2 | |
:set number | |
:set ruler |
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-13 ports) | |
(define (s->json s) | |
(cond | |
((and (pair? s) (string? (car s))) | |
(sprintf "~a:~a" | |
(s->json (car s)) | |
(s->json (cdr s)))) | |
((pair? s) | |
(sprintf "{~a}" | |
(string-join (map s->json s) ","))) |
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-69) | |
(define h (make-hash-table eq? hash-by-identity)) | |
(define a (cons 'a 'b)) | |
(define b (cons 'a 'b)) | |
(hash-table-set! h a 10) | |
(hahs-table-set! h b 20) | |
(hash-table-ref h a) | |
; ==> 10 |
OlderNewer