blob: 64c633e4245878f49d1178fc0d424697b2c7b8cf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
;;; (boudin util) --- utility functions
(define-library (boudin util)
(import (scheme base)
(scheme case-lambda)
(scheme eval))
(export identity
o
assoc-ref
slurp
eval/q)
(begin
(define (identity x) x)
(define (o . procs) ; stole from chicken core
(if (null? procs)
identity
(let loop ((procs procs))
(let ((h (car procs))
(t (cdr procs)))
(if (null? t)
h
(lambda (x) (h ((loop t) x))))))))
(define assoc-ref
(case-lambda
((key alist)
(assoc-ref alist
key
(lambda () (error "Unrecognized key." key))))
((key alist failure)
(cond ((assoc key alist) => cdr)
(else (failure))))))
(define slurp
(case-lambda
(() (slurp (current-input-port)))
((port)
(let loop ((ch (read-char))
(acc '()))
(if (eof-object? ch)
(list->string (reverse acc))
(loop (read-char) (cons ch acc)))))))
(define (eval/q form env) ; this is probably a bad idea
(eval (list 'quasiquote form) env))
))
|