mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-15 16:57:35 +02:00
Setting stage for string->list in scheme
This commit is contained in:
parent
f94b984f67
commit
05f6d53fd4
1 changed files with 11 additions and 0 deletions
|
@ -49,6 +49,7 @@
|
||||||
vector-fill!
|
vector-fill!
|
||||||
vector->list
|
vector->list
|
||||||
vector->string
|
vector->string
|
||||||
|
my-string->list
|
||||||
string->vector
|
string->vector
|
||||||
make-parameter
|
make-parameter
|
||||||
current-output-port
|
current-output-port
|
||||||
|
@ -216,6 +217,16 @@
|
||||||
(define (vector->string vec . opts)
|
(define (vector->string vec . opts)
|
||||||
(let ((lst (apply vector->list (cons vec opts))))
|
(let ((lst (apply vector->list (cons vec opts))))
|
||||||
(list->string lst)))
|
(list->string lst)))
|
||||||
|
(define (my-string->list str . opts)
|
||||||
|
(letrec ((len (string-length str))
|
||||||
|
(start (if (> (length opts) 0) (car opts) 0))
|
||||||
|
(end (if (> (length opts) 1) (cadr opts) len))
|
||||||
|
(loop (lambda (i lst)
|
||||||
|
(if (= i end)
|
||||||
|
(reverse lst)
|
||||||
|
(loop (+ i 1)
|
||||||
|
(cons (string-ref str i) lst))))))
|
||||||
|
(loop start '())))
|
||||||
;; TODO: need to extend string->list to take optional start/end args,
|
;; TODO: need to extend string->list to take optional start/end args,
|
||||||
;; then modify this function to work with optional args, too
|
;; then modify this function to work with optional args, too
|
||||||
(define (string->vector str . opts)
|
(define (string->vector str . opts)
|
||||||
|
|
Loading…
Add table
Reference in a new issue