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
(import | |
(scheme base) | |
(scheme write) | |
(scheme cxr) | |
(picrin macro)) | |
(define-syntax destructuring-bind | |
(ir-macro-transformer | |
(lambda (form inject compare) | |
(let ((pattern (cadr form)) |
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
(destructuring-bind ((a b) . c) '((1 2) 3 4 5) (list a b c)) | |
; expands to | |
((lambda (evaluated@605) | |
((lambda (evaluated@605) | |
((lambda (a@617) | |
(begin ((lambda (evaluated@605) | |
((lambda (b@619) | |
(begin |
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 aif | |
(sc-macro-transformer | |
(lambda (form env) | |
`(let ((it ,(make-sc env '() pred))) | |
(aif* ,@(cddr form)))))) | |
(define-syntax aif* | |
(sc-macro-transformer | |
(lambda (form env) | |
(let ((then (cadr form)) |
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
picrin$ cmake . | |
-- The C compiler identification is GNU 4.8.2 | |
-- The CXX compiler identification is GNU 4.8.2 | |
-- Check for working C compiler: /usr/bin/cc | |
-- Check for working C compiler: /usr/bin/cc -- works | |
-- Detecting C compiler ABI info | |
-- Detecting C compiler ABI info - done | |
-- Check for working CXX compiler: /usr/bin/c++ | |
-- Check for working CXX compiler: /usr/bin/c++ -- works | |
-- Detecting CXX compiler ABI info |
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
(import (scheme base)) | |
(import (scheme cxr)) | |
(import (picrin macro)) | |
(import (scheme write)) | |
;;; utility functions | |
(define (reverse* l) | |
;; (reverse* '(a b c d . e)) => (e d c b . a) | |
(let loop ((r (car l)) | |
(l (cdr l))) |
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 let-values | |
(syntax-rules () | |
((let-values (binding ...) body0 body1 ...) | |
(let-values "bind" | |
(binding ...) () (begin body0 body1 ...))) | |
((let-values "bind" () tmps body) | |
(let tmps body)) | |
((let-values "bind" ((b0 e0) | |
binding ...) tmps body) | |
(let-values "mktmp" b0 e0 () |
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
(er-macro-transformer@176 | |
(lambda (expr@1459 rename@1460 cmp@1461) | |
(define (reverse*@1463 l@1462) | |
((lambda () | |
(define loop@1464 | |
(lambda (r@1465 l@1466) | |
(if (pair?@6 l@1466) | |
(loop@1464 | |
(cons@7 (car@8 l@1466) r@1465) | |
(cdr@9 l@1466)) |
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
;; このsyntax-rulesが | |
(syntax-rules () | |
((let name ((var init) ...) body ...) | |
((lambda () | |
(define (name var ...) | |
body ...) | |
(name init ...)))) | |
((let ((var init) ...) body ...) | |
((lambda (var ...) body ...) init ...))) |
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 syntax-rules | |
(er-macro-transformer | |
(lambda (expr rename compare) | |
(let ((ellipsis-specified? (identifier? (cadr expr))) | |
(count 0) | |
(_er-macro-transformer (rename 'er-macro-transformer)) | |
(_lambda (rename 'lambda)) (_let (rename 'let)) | |
(_begin (rename 'begin)) (_if (rename 'if)) | |
(_and (rename 'and)) (_or (rename 'or)) | |
(_eq? (rename 'eq?)) (_equal? (rename 'equal?)) |
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
(* Q1 *) | |
let rec sum_to n = | |
match n with | |
| 0 -> 0 | |
| n -> n + sum_to (n - 1) | |
(* Q2*) | |
let rec fib_exp n = | |
match n with | |
| 0 -> 1 |
OlderNewer