Relocated string-join and added string-split

This commit is contained in:
Justin Ethier 2017-08-23 12:02:53 +00:00
parent e2e2232146
commit 922eb69658
3 changed files with 15 additions and 18 deletions

View file

@ -8,7 +8,6 @@ The `(scheme cyclone cgen)` library compiles scheme code to a Cheney-on-the-MTA
- [`emits`](#emits)
- [`emits*`](#emits-1)
- [`emit-newline`](#emit-newline)
- [`string-join`](#string-join)
# mta:code-gen
@ -46,9 +45,4 @@ Call `emits` for each of the given strings.
`display` a newline to the current output port.
# string-join
(string-join list deliminator)
Create a single string from a list of strings, adding `deliminator` between each of the strings.

View file

@ -60,7 +60,9 @@ The `(scheme cyclone util`) library contains various utility functions.
- [`set!->exp `](#set-exp)
- [`set!->var `](#set-var)
- [`set!? `](#set)
- [`string-join `](#string-join)
- [`string-replace-all `](#string-replace-all)
- [`string-split `](#string-split)
- [`tagged-list? `](#tagged-list?)
- [`take `](#take)
@ -180,8 +182,21 @@ The `(scheme cyclone util`) library contains various utility functions.
# set!?
# string-join
(string-join list deliminator)
Create a single string from a list of strings, adding `deliminator` between each of the strings. `deliminator` may be either a character or string.
# string-replace-all
# string-split
(string-split string deliminator)
Create a list of strings from the given string, creating a new one at each instance of the `deliminator` character.
# tagged-list?
# take

View file

@ -54,18 +54,6 @@
(define (emit-newline)
(newline))
(define (string-join lst delim)
(cond
((null? lst)
"")
((= (length lst) 1)
(car lst))
(else
(string-append
(car lst)
delim
(string-join (cdr lst) delim)))))
;; Escape chars in a C-string, so it can be safely written to a C file
(define (cstr:escape-chars str)
(letrec ((next (lambda (head tail)