(define (test obj)
(cond
((string? obj) (format "'%s'" obj))
((list? obj) (format "[ %s ]" (join (map test obj) ", ")))))
;; expected:
;; (test '(("foo" "bar") ("baz" "bat")))
;; "[ [ 'foo', 'bar' ], [ 'baz', 'bat' ] ]"
;; received:
(test '(("foo" "bar") ("baz" "bat")))
"[ [ 'foo', 'bar', [ 'baz', 'bat' ]"
'format' has an old reentrance problem, which needs to be fixed.
Meanwhile use this workaround:
(define (test obj)
(cond
((string? obj) (format "'%s'" obj))
((list? obj)
(let (s (join (map test obj) ", "))
(format "[ %s ]" s)))))
> (test '(("foo" "bar") ("baz" "bat")))
"[ [ 'foo', 'bar' ], [ 'baz', 'bat' ] ]"
Thanks. I'm already working around using 'string' :)