This file contains hidden or 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 | |
(import (rnrs)) | |
(define-syntax define-dummy | |
(syntax-rules () | |
((_ body ...) | |
(define dummy | |
(begin | |
body ... | |
#t))))) |
This file contains hidden or 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 (rnrs)) | |
(define-syntax foo | |
(lambda (x) | |
(syntax-case x () | |
((k) | |
(with-syntax (((x ...) (datum->syntax #'k '(a b c)))) | |
#'(begin (display '(x ...)) (newline))))))) | |
(foo) |
This file contains hidden or 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 (rnrs) (only (chezscheme) time)) | |
;;(import (rnrs) (only (racket base) time)) | |
;;(import (rnrs) (time)) | |
(define (tt a1 a2) a1) | |
(define (ff a1 a2) a2) | |
(define (slot-f f l) (fold-right (lambda (a f) (f a)) f l)) | |
(define (build-k j as k) | |
(lambda (r) | |
(lambda (a1) |
This file contains hidden or 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 | |
(import (rnrs)) | |
(define (fast-inv-sqrt f) | |
(let ((bv (make-bytevector 4))) | |
(bytevector-ieee-single-native-set! bv 0 f) | |
(let* ((i0 (bitwise-arithmetic-shift (bytevector-s32-native-ref bv 0) -1)) | |
(i1 (- #x5f3759df i0))) | |
(bytevector-s32-native-set! bv 0 i1) | |
(let ((y (bytevector-ieee-single-native-ref bv 0))) |
This file contains hidden or 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 (rnrs) | |
(prefix (binary io) binary:) | |
(util bytevector)) | |
;; assume all UTF-8 and EOL is \n | |
;; It's as close as O(1) memory space. | |
;; The amount of memory usage is O(m), m is the length of one line. | |
;; (and I think reading one line isn't that bad comparing storing n lines) | |
;; It is possible to make this actual O(1) to search port each time set | |
;; port position. But I don't think that's a good trade off (it doesn't pay off). |
This file contains hidden or 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
;; expression must already be expanded by expander | |
;; so it shall only have the following syntaxes: | |
;; - define | |
;; - lambda | |
;; - set! | |
;; - quote | |
;; - if | |
;; - begin | |
;; NB: by this point, all of the optimisation in Scheme level | |
;; must be done. (e.g. constant folding) |
This file contains hidden or 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)) | |
;; copier | |
(define *copier-table* '()) | |
(define (generic-copy obj) | |
(cond ((assoc obj *copier-table* (lambda (x p) (p x))) => | |
(lambda (s) ((cdr s) obj))) | |
;; shallow copy, sort of | |
(else obj))) | |
(define (register-copier! pred copier) |
This file contains hidden or 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
postit=> \d users | |
Table "public.users" | |
Column | Type | Modifiers | |
-------------+-----------------------------+------------------------------------------------- | |
id | integer | not null default nextval('users_seq'::regclass) | |
username | character varying | not null | |
password | character varying | not null | |
create_date | timestamp without time zone | default now() | |
Indexes: | |
"users_pkey" PRIMARY KEY, btree (id) |
This file contains hidden or 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 | |
(import (rnrs)) | |
(define-syntax match | |
(lambda (x) | |
;; extract identifier in pattern | |
(define (parse-pattern pattern) | |
(let loop ((p pattern) (acc '())) | |
(syntax-case p () | |
(() (reverse acc)) |
This file contains hidden or 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
;; for Sagittarius, Ypsilon | |
(import (rnrs) (time)) | |
;; for Mosh | |
;; (import (rnrs) (mosh)) | |
;; for Chez with --script option | |
;; (import (rnrs)) | |
;; for Vicare | |
;; (import (rnrs) (vicare)) | |
;; for Racket | |
;; (import (rnrs) (only (racket base) time)) |