summaryrefslogtreecommitdiff
path: root/scheme
diff options
context:
space:
mode:
authormichele.simionato <devnull@localhost>2009-03-17 15:31:19 +0000
committermichele.simionato <devnull@localhost>2009-03-17 15:31:19 +0000
commitde79d8a56edd56d1edbc5515e976dcc809ff98d9 (patch)
tree727dc579af4a70f68357fdacb757132e2cd227d2 /scheme
parent5ac87f1d80f861f1ecffac2fcb60701434cbf3d0 (diff)
downloadmicheles-de79d8a56edd56d1edbc5515e976dcc809ff98d9.tar.gz
Minor changes
Diffstat (limited to 'scheme')
-rw-r--r--scheme/aps/lang.sls3
-rw-r--r--scheme/aps/string-utils.sls16
2 files changed, 11 insertions, 8 deletions
diff --git a/scheme/aps/lang.sls b/scheme/aps/lang.sls
index f2da11e..1693259 100644
--- a/scheme/aps/lang.sls
+++ b/scheme/aps/lang.sls
@@ -9,7 +9,8 @@
(sub (: let-form e)
#'e)
(sub (: let-form e1 e2)
- (syntax-violation ': "Odd number of arguments" #'(let-form e1 e2)))
+ (syntax-violation ': "Odd number of arguments"
+ (syntax->datum #'(let-form e1 e2))))
(sub (: let-form patt value rest ... expr)
#'(let-form ((patt value)) (: let-form rest ... expr))
(identifier? #'let-form)
diff --git a/scheme/aps/string-utils.sls b/scheme/aps/string-utils.sls
index 8e8aaf1..0d6b8c0 100644
--- a/scheme/aps/string-utils.sls
+++ b/scheme/aps/string-utils.sls
@@ -1,21 +1,23 @@
(library (aps string-utils)
(export string-split)
-(import (rnrs))
+(import (rnrs) (aps compat))
+;;STRING-SPLIT
+;; adapted from http://schemecookbook.org/Cookbook/StringSplit
+;; to match Python behaviour
(define (string-split str ch)
(define len (string-length str))
(define (split a b)
+ ;(printf "~a: ~a ~a\n" str a b)
(cond
((>= b len)
- (if (= a b) '()
+ (if (= a b) '("")
(list (substring str a b))))
((char=? ch (string-ref str b))
- (if (= a b) (split (+ 1 a) (+ 1 b))
+ (if (= a b) (let ((res (split (+ 1 a) (+ 1 b))))
+ (if (= 0 a) (cons "" res) res))
(cons (substring str a b) (split b b))))
(else (split a (+ 1 b)))))
(split 0 0))
+;;END
)
-
-;(display (string-split "a.b" #\.))
-;(display (string-split ".b" #\.))
-;(display (string-split "a." #\.))