Skip to content

Instantly share code, notes, and snippets.

View shirok's full-sized avatar

Shiro Kawai shirok

View GitHub Profile
shiro@scherzo:~/src$ gosh ./tt.scm a b c gosh ./t.scm
shiro@scherzo:~/src$ cat a
out
out
out
out
out
out
out
out
shiro@scherzo:~/src$ gosh ./t.scm 3>c > >(tee a >&3) 2> >(tee b >&3)
shiro@scherzo:~/src$ cat a
out
out
out
out
out
out
out
out
(define x 0) ; x_0
(let ((x 1)) ; x_1
(let-syntax ((foo (syntax-rules ()
((_) x))))
(let ((x 2)) ; x_2
(foo)))) ; => 1
;; fooの展開で現れるxは、fooの使用位置から見えるx_2ではなく、
;; fooの定義位置から見えるx_1。
gosh> (let-syntax ((foo (syntax-rules () ((_ a) (quote (a a))))))
(%macroexpand (foo foo)))
(#<identifier user#quote.1c06de0> (foo foo))
(use gauche.sequence)
;; (xrotate '(x a b c d e) 3) -> (a b c x d e) etc.
(define (xrotate lis n)
`(,@(subseq lis 1 (+ n 1)) ,(car lis) ,@(drop lis (+ n 1))))
(define (digit->column n)
`(#\# ,@(xrotate '(#\o #\|) (div n 5)) #\# ,@(xrotate '(#\| #\o #\o #\o #\o) (mod n 5)) #\#))
(define (num->columns num width)
(define-library (scheme linear-algebra)
(import (rename (scheme base) (* r7rs:*)))
(export *)
(begin
(define (* x y)
(if (or (array? x) (array? y))
(array-multiplication x y)
(r7rs:* x y)))
(define (array? obj) ...)
diff --git a/src/class.c b/src/class.c
index cdebd2c..9b6a1e3 100644
--- a/src/class.c
+++ b/src/class.c
@@ -2701,6 +2701,11 @@ static void accessor_method_slot_accessor_set(ScmAccessorMethod *m, ScmObj v)
* Foreign pointer mechanism
*/
+/* foreign pointer instance flags */
+enum {
(defvar orig-list-reader (get-macro-character #\())
(set-macro-character #\( (lambda (stream ch)
(let ((lis (funcall orig-list-reader stream ch)))
(if (eq (car lis) 'comment) (values) lis))))
;; モジュールgauche.baseがr7rsを読まないと定義されないので、読んどく (次のバージョンで直す)
(require "r7rs")
;; gauche.baseから不要なもの以外をインポート
(import (gauche.base :except (quote)))
;; 継承を切る
(extend)
;; define => #<syntax define>
(define (map_ proc lis)
(map1 proc lis 0))
(define (map1 proc lis n)
(cond [(null? lis) '()]
[(> n 30) (reverse (fold (^[elt r] (cons (proc elt) r)) '() lis))]
[else (cons (proc (car lis)) (map1 proc (cdr lis) (+ n 1)))]))
#|
gosh> (use gauche.time)