scheme

racket module nest and global variable

Let us consider the case global variable my-global-var is exported in module sub-sub.scm sub-sub.scm #lang racket (provide my-global-var print-my-global-var set-my-global-var!) (define my-global-var "global in sub-sub") (define (print-my-g…

fuild-let example

ref http://karetta.jp/book-node/gauche-hacks/014781 #lang racket (define x 200) (define (test) x) (test) ;=>200 (let ((x 50)) (test)) ;=>200 (require mzscheme) (fluid-let ((x 50)) (test)) ;=>50

stalingrad

stalinよりも高速だというstalingradを試してみた。 doを認識しない。ループは letrec loopのみ。 そのままでは、ちょっと使えなさそう

Gauche0.9 CiSE example

CiSE usage simple example cise ;save as cise-simple-example.scm (define-cise-stmt (mywhen test . body) `(if ,test (begin ,@body))) (define-cfn test1 (aa::int ) ::void (mywhen (> aa 50 ) (test2)) ) (define-cfn test2 (argc::int argv::char**)…

recursive miniKanren

cKanrenもminiKanrenも再帰関係を記述できない > (run* (q) (== q `(3 ,q))) ;; should be #0 = ( 3 . #0#) '() 実行すると「そんな関係は存在しない」という答 '() が帰ってくる。説明のためもう少し複雑な例を使う。これでも同様 > (run* (q) (fresh (x) (…

Scheme? -> cKanren

usage (run* (x) (== x 3) (scm?->ck number? x));=>(3) (run* (x) (scm?->ck number? x) ;;project does not work in this order (== x 3)) ;=>(3) (run* (x) (== x 'a) (scm?->ck number? x));=>'() (run* (q) (fresh (x y) (== x 3) (== y 5) (scm?->ck <…

schelog %let danger

#lang scheme (require racklog) (define %derive-type (%let ( X Y T) (%rel ( ) [( (list '+ X Y ) 'pls) ] ))) (%which (T) (%derive-type '(+ z y ) T )) ;=> ((T . pls)) (%which (X Y T) (%derive-type (list '+ X Y ) T )); => ((X . z) (Y . y) (T .…

cKanren Racket

https://github.com/niitsuma/cKanrenfork from http://rkrishnan.org/blog/2012/01/09/ckanren/ and little bug fixedUsage:samealso can use (require cKanren) #lang racket (require cKanren) (run* (q) (== q 3)) more extension (but still buggy) htt…

stalin can not optimize stream

Re: A fast scheme implementation? http://newsgroups.derkeiler.com/Archive/Comp/comp.lang.scheme/2007-12/msg00061.html ftp://ftp.ecn.purdue.edu/qobi/integ.tgzでstalinが非常に高速なことを示す例としてあげられている積分プログラムをstreamで書き…

give up run lalr-scm in racket

I try to run lalr.scm on racket. but give up.http://www.suri.cs.okayama-u.ac.jp/~niitsuma/lalr.rkthttp://www.suri.cs.okayama-u.ac.jp/~niitsuma/calc.rkt

match macro difference

Gauche OK (use srfi-1) (use util.match) (match '(0 (1 2) (3 4 5)) [(a (b c) (d e f)) (list a b c d e f)]) (match '(0 (1 2) (3 4 5)) [`(,a (,b ,c) (,d ,e ,f)) (list a b c d e f)]) racket Err #lang scheme (require racket/match) (match '(0 (1…

stalin bug

stalin-0.11/include/QobiScheme.sc stalin-0.11/benchmarks/em-functional.sc (define (reduce-vector f v i) (let ((n (vector-length v))) (cond ((zero? n) i) ((= n 1) (vector-ref v 0)) (else (let loop ((i 1) (c (vector-ref v 0))) (if (= i n) c …

schelog %= %==

(%which (X Y Z U V W ) (%== (list X Y Z) (list U V W) )) >#f (%which (X Y Z U V W ) (%= (list X Y Z) (list U V W) )) >'((X . _) (Y . _) (Z . _) (U . _) (V . _) (W . _)) (%which (X Y Z U V W ) (%= (list X Y Z) (list U V ) )) >#f