mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-12 07:17:37 +02:00
Added more string functions
This commit is contained in:
parent
05f6d53fd4
commit
4c0ce77892
2 changed files with 42 additions and 2 deletions
5
TODO
5
TODO
|
@ -7,6 +7,11 @@ Working TODO list. should start creating issues for these to get them out of her
|
||||||
|
|
||||||
- self-hosting, there are a lot of accumulated TODO's that need to be addressed
|
- self-hosting, there are a lot of accumulated TODO's that need to be addressed
|
||||||
|
|
||||||
|
- adding r7rs support
|
||||||
|
- vectors - add test cases from r7rs
|
||||||
|
- strings - finish adding functions, then add test cases
|
||||||
|
- review other sections from the report
|
||||||
|
|
||||||
- improved error handling:
|
- improved error handling:
|
||||||
- param count checks
|
- param count checks
|
||||||
if a primitive is called directly, shouldn't it be possible to check arg count?
|
if a primitive is called directly, shouldn't it be possible to check arg count?
|
||||||
|
|
|
@ -40,8 +40,6 @@
|
||||||
boolean=?
|
boolean=?
|
||||||
symbol=?
|
symbol=?
|
||||||
Cyc-obj=?
|
Cyc-obj=?
|
||||||
make-string
|
|
||||||
string
|
|
||||||
vector
|
vector
|
||||||
vector-append
|
vector-append
|
||||||
vector-copy
|
vector-copy
|
||||||
|
@ -49,8 +47,17 @@
|
||||||
vector-fill!
|
vector-fill!
|
||||||
vector->list
|
vector->list
|
||||||
vector->string
|
vector->string
|
||||||
|
make-string
|
||||||
|
string
|
||||||
|
string-copy
|
||||||
|
string-copy!
|
||||||
|
string-fill!
|
||||||
my-string->list
|
my-string->list
|
||||||
string->vector
|
string->vector
|
||||||
|
; TODO:
|
||||||
|
;string-upcase
|
||||||
|
;string-downcase
|
||||||
|
;string-foldcase
|
||||||
make-parameter
|
make-parameter
|
||||||
current-output-port
|
current-output-port
|
||||||
current-input-port
|
current-input-port
|
||||||
|
@ -217,6 +224,7 @@
|
||||||
(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)))
|
||||||
|
;; TODO: change to string->list
|
||||||
(define (my-string->list str . opts)
|
(define (my-string->list str . opts)
|
||||||
(letrec ((len (string-length str))
|
(letrec ((len (string-length str))
|
||||||
(start (if (> (length opts) 0) (car opts) 0))
|
(start (if (> (length opts) 0) (car opts) 0))
|
||||||
|
@ -232,6 +240,33 @@
|
||||||
(define (string->vector str . opts)
|
(define (string->vector str . opts)
|
||||||
(list->vector
|
(list->vector
|
||||||
(string->list str)))
|
(string->list str)))
|
||||||
|
(define (string-copy str . opts)
|
||||||
|
(letrec ((len (string-length str))
|
||||||
|
(start (if (> (length opts) 0) (car opts) 0))
|
||||||
|
(end (if (> (length opts) 1) (cadr opts) len)))
|
||||||
|
(substring str start end)))
|
||||||
|
(define (string-copy! to at from . opts)
|
||||||
|
(letrec ((len (string-length from))
|
||||||
|
(start (if (> (length opts) 0) (car opts) 0))
|
||||||
|
(end (if (> (length opts) 1) (cadr opts) len))
|
||||||
|
(loop (lambda (i-at i-from)
|
||||||
|
(cond
|
||||||
|
((= i-from end) to)
|
||||||
|
(else
|
||||||
|
(string-set! to i-at (string-ref from i-from))
|
||||||
|
(loop (+ i-at 1) (+ i-from 1)))))))
|
||||||
|
(loop at start)))
|
||||||
|
(define (string-fill! str fill . 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)
|
||||||
|
(cond
|
||||||
|
((= i end) str)
|
||||||
|
(else
|
||||||
|
(string-set! str i fill)
|
||||||
|
(loop (+ i 1)))))))
|
||||||
|
(loop start)))
|
||||||
(define (vector-append . vecs)
|
(define (vector-append . vecs)
|
||||||
(list->vector
|
(list->vector
|
||||||
(apply append (map vector->list vecs))))
|
(apply append (map vector->list vecs))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue