about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2023-08-13 22:59:29 -0500
committerCase Duckworth2023-08-13 22:59:29 -0500
commit246ee2e48fa40b7534e294f219f99688a3c823eb (patch)
tree5c453d3c81a686fe4125470c0d9f8f2210da1d71
parentProperly export utf8 (diff)
downloadchicanery-246ee2e48fa40b7534e294f219f99688a3c823eb.tar.gz
chicanery-246ee2e48fa40b7534e294f219f99688a3c823eb.zip
Update extras
-rw-r--r--chicanery.extras.scm58
-rw-r--r--chicanery.scm6
2 files changed, 53 insertions, 11 deletions
diff --git a/chicanery.extras.scm b/chicanery.extras.scm index 27968df..bcb4929 100644 --- a/chicanery.extras.scm +++ b/chicanery.extras.scm
@@ -1,8 +1,7 @@
1;;; chicanery extras --- extra stuff from ur old pal acdw 1;;; chicanery extras --- extra stuff from ur old pal acdw
2 2
3(export list-map 3(export list-map list-for-each list-append
4 list-for-each 4 map for-each append)
5 list-append)
6 5
7;;; Generalized map, for-each, ... 6;;; Generalized map, for-each, ...
8;; List versions are renamed `list-<function>'. Un-prefixed versions work 7;; List versions are renamed `list-<function>'. Un-prefixed versions work
@@ -81,13 +80,9 @@
81;;; Functions that should be in scheme 80;;; Functions that should be in scheme
82;; This sections should be as small as possible 81;; This sections should be as small as possible
83 82
84(export atom? 83(export read-port
85 read-port
86 read-port-chunk-size) 84 read-port-chunk-size)
87 85
88(define (atom? x)
89 (not (pair? x)))
90
91(define read-port-chunk-size 86(define read-port-chunk-size
92 (make-parameter 512)) 87 (make-parameter 512))
93 88
@@ -113,3 +108,50 @@
113 (case-lambda 108 (case-lambda
114 (() (%read-port (current-input-port))) 109 (() (%read-port (current-input-port)))
115 ((p) (%read-port p)))) 110 ((p) (%read-port p))))
111
112(export atom? defined?)
113
114(define (atom? x)
115 (not (or (null? x)
116 (pair? x))))
117
118(define (defined? sym)
119 (call-with-current-continuation
120 (lambda (k)
121 (with-exception-handler
122 (lambda (e) (k #f))
123 (lambda ()
124 (eval sym (interaction-environment))
125 #t)))))
126
127(export with-output-to-string
128 with-input-from-string)
129
130(define (with-output-to-string thunk)
131 (call-with-port (open-output-string)
132 (lambda (port)
133 (parameterize ((current-output-port port))
134 (thunk))
135 (get-output-string port))))
136
137(define (with-input-from-string s thunk)
138 (call-with-port (open-input-string s)
139 (lambda (port)
140 (parameterize ((current-input-port port))
141 (thunk)))))
142
143(export displayed ->string written print)
144
145(define (displayed x)
146 (with-output-to-string
147 (lambda () (display x))))
148
149(define (written x)
150 (with-output-to-string
151 (lambda () (write x))))
152
153(define (print . xs)
154 (for-each display xs)
155 (newline))
156
157(define ->string displayed)
diff --git a/chicanery.scm b/chicanery.scm index 12f5ab3..0fc71e4 100644 --- a/chicanery.scm +++ b/chicanery.scm
@@ -20,7 +20,7 @@
20 (import (scheme time)) 20 (import (scheme time))
21 (import (scheme write)) 21 (import (scheme write))
22 (import utf8) 22 (import utf8)
23 (export * + - / <= < >= = > abs and append apply assoc assq assv begin 23 (export * + - / <= < >= = > abs and #;append apply assoc assq assv begin
24 binary-port? boolean? boolean=? bytevector bytevector-append 24 binary-port? boolean? boolean=? bytevector bytevector-append
25 bytevector-copy bytevector-copy! bytevector-length bytevector-u8-ref 25 bytevector-copy bytevector-copy! bytevector-length bytevector-u8-ref
26 bytevector-u8-set! bytevector? car cdr caar cadr cdar cddr 26 bytevector-u8-set! bytevector? car cdr caar cadr cdar cddr
@@ -34,13 +34,13 @@
34 error-object-message error-object? even? odd? exact inexact 34 error-object-message error-object? even? odd? exact inexact
35 exact-integer-sqrt exact-integer? exact? inexact? exp expt features 35 exact-integer-sqrt exact-integer? exact? inexact? exp expt features
36 file-error? floor floor/ floor-quotient floor-remainder 36 file-error? floor floor/ floor-quotient floor-remainder
37 flush-output-port for-each gcd lcm get-output-bytevector 37 flush-output-port #;for-each gcd lcm get-output-bytevector
38 get-output-string guard if import import-for-syntax include include-ci 38 get-output-string guard if import import-for-syntax include include-ci
39 input-port-open? output-port-open? input-port? output-port? integer? 39 input-port-open? output-port-open? input-port? output-port? integer?
40 lambda length let let* letrec letrec* let-values let*-values let-syntax 40 lambda length let let* letrec letrec* let-values let*-values let-syntax
41 letrec-syntax list list-copy list-ref list-set! list-tail list? 41 letrec-syntax list list-copy list-ref list-set! list-tail list?
42 list->vector make-bytevector make-list make-parameter make-string 42 list->vector make-bytevector make-list make-parameter make-string
43 make-vector map max min member memq memv modulo remainder negative? 43 make-vector #;map max min member memq memv modulo remainder negative?
44 positive? newline not null? number->string string->number number? 44 positive? newline not null? number->string string->number number?
45 open-input-bytevector open-output-bytevector open-input-string 45 open-input-bytevector open-output-bytevector open-input-string
46 open-output-string or pair? parameterize peek-char peek-u8 port? 46 open-output-string or pair? parameterize peek-char peek-u8 port?