Skip to content

Instantly share code, notes, and snippets.

View shirok's full-sized avatar

Shiro Kawai shirok

View GitHub Profile
gosh> (define (map+ ls)
(if (null? ls)
0
(+ (car ls) (map+ (cdr ls)))))
map+
gosh> (map+ '(1 2 3))
6
(define (f) (call/cc (lambda (k) ...)) (print "baz"))
(define (g) (f) (print "foo"))
(define (h) (g) (a) (print "bar"))
(define (a) ...)
printが入れてあるのはTCOで話をややこしくしないため。
(h) を呼び出して実行が進み、(a)に入った時点で、スタックフレームだけ考えると
diff --git a/lib/gauche/process.scm b/lib/gauche/process.scm
index 069348e..683ab6e 100644
--- a/lib/gauche/process.scm
+++ b/lib/gauche/process.scm
@@ -382,6 +382,7 @@
[gauche.sys.threads
(receive (in out) (sys-pipe)
(push! iomap `(,fd . ,in))
+ (push! toclose in)
(thread-start! (make-thread (cut write-arg out))))]
(defmacro when-let* [bindings & body]
(letfn [(rec
([] `(do ~@body))
([var expr & rest] `(if-let [~var ~expr] ~(apply rec rest)))
([var] (throw (Exception. "Odd element in bindings of if-let*"))))]
(apply rec bindings)))
;; Emacs users want this:
;; (put 'when-let* 'clojure-indent-function 1)
(define-module foo
(export <foo> foo-a foo-b)
(define-class <foo> ()
((#0=#:a :init-keyword :a)
(#1=#:b :init-keyword :b)))
(define (foo-a x) (~ x '#0#))
(define (foo-b x) (~ x '#1#)))
$ gcc --version
gcc.exe (x86_64-win32-seh-rev1, Built by MinGW-W64 project) 5.2.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ grep THREAD gc/config.status
S["WIN32_THREADS_FALSE"]="#"
S["WIN32_THREADS_TRUE"]=""
S["DARWIN_THREADS_FALSE"]=""
(define-method object-apply ((operand <top>) arg . args)
(let* ([args (cons arg args)]
[operator (find (^a (or (is-a? a <procedure>)
(is-a? a <generic>)))
args)]
[operands (map (^a (if (is-a? a <kwoted>)
(~ a'fn)
a))
(cons operand (delete operator args)))])
(unless operator
(define-method object-apply ((operand <top>) arg . args)
(let* ([args (cons arg args)]
[operator (find (^a (or (is-a? a <procedure>)
(is-a? a <generic>)))
args)]
[operands (cons operand (delete operator args))])
(unless operator
(error "No operator in application form:" (cons operand args)))
(apply operator operands)))
#include <stdio.h>
#include <math.h>
float a(float x)
{
return x + 0.25f - 0.25f;
}
float b(float x)
{
$ clisp
i i i i i i i ooooo o ooooooo ooooo ooooo
I I I I I I I 8 8 8 8 8 o 8 8
I \ `+' / I 8 8 8 8 8 8
\ `-+-' / 8 8 8 ooooo 8oooo
`-__|__-' 8 8 8 8 8
| 8 o 8 8 o 8 8
------+------ ooooo 8oooooo ooo8ooo ooooo 8
Welcome to GNU CLISP 2.49 (2010-07-07) <http://clisp.cons.org/>