forked from okuoku/xitomatl
-
Notifications
You must be signed in to change notification settings - Fork 1
/
common.nmosh.sls
53 lines (43 loc) · 1.41 KB
/
common.nmosh.sls
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
51
52
53
;; based on ypsilon one
;; [[ORIGINAL COPYRIGHT STATEMENT]]
;; Copyright 2009 Derick Eddington. My MIT-style license is in the file named
;; LICENSE from the original collection this file is distributed with.
(library (xitomatl common)
(export
add1 sub1
format printf fprintf pretty-print
gensym
time
; do not support them (currently)
;with-input-from-string with-output-to-string
;system
;; TODO: add to as needed/appropriate
)
(import
(rnrs)
(nmosh gensym)
(mosh pp)
(only (mosh) time format))
(define (add1 x) (+ x 1))
(define (sub1 x) (- x 1))
(define (fprintf port fmt-str . fmt-args)
(put-string port (apply format fmt-str fmt-args)))
(define (printf fmt-str . fmt-args)
(apply fprintf (current-output-port) fmt-str fmt-args))
#|
(define (parameterize-current-port port set-port! val thunk)
(define (swap)
(let ((t (port)))
(set-port! val)
(set! val t)))
(dynamic-wind swap thunk swap))
(define (with-input-from-string str thunk)
(parameterize-current-port current-input-port set-current-input-port!
(open-string-input-port str) thunk))
(define (with-output-to-string thunk)
(let-values (((sop get) (open-string-output-port)))
(parameterize-current-port current-output-port set-current-output-port!
sop thunk)
(get)))
|#
)