mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-15 00:37:35 +02:00
Added string/vector functions
This commit is contained in:
parent
d19db2625a
commit
af2c85b9a4
3 changed files with 15 additions and 9 deletions
|
@ -32,10 +32,10 @@ Section | Status | Comments
|
||||||
6.4 Pairs and lists | Yes | `member` functions are predicates, `member` and `assoc` do not accept `compare` argument.
|
6.4 Pairs and lists | Yes | `member` functions are predicates, `member` and `assoc` do not accept `compare` argument.
|
||||||
6.5 Symbols | Yes |
|
6.5 Symbols | Yes |
|
||||||
6.6 Characters | Partial | No unicode support, `char-ci` predicates are not implemented.
|
6.6 Characters | Partial | No unicode support, `char-ci` predicates are not implemented.
|
||||||
6.7 Strings | Partial | Many functions are missing. Need to sync up with r7rs.
|
6.7 Strings | Partial | No unicode support, `string-ci` functions are not implemented.
|
||||||
6.8 Vectors | Yes |
|
6.8 Vectors | Yes |
|
||||||
6.9 Bytevectors | |
|
6.9 Bytevectors | | Not supported yet.
|
||||||
6.10 Control features | |
|
6.10 Control features | | The `map` functions only support one "data" argument - for example, `string-map` only accepts one string.
|
||||||
6.11 Exceptions | Partial | Need to check against r7rs
|
6.11 Exceptions | Partial | Need to check against r7rs
|
||||||
6.12 Environments and evaluation | Partial |
|
6.12 Environments and evaluation | Partial |
|
||||||
6.13 Input and output | |
|
6.13 Input and output | |
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
vector-fill!
|
vector-fill!
|
||||||
vector->list
|
vector->list
|
||||||
vector->string
|
vector->string
|
||||||
|
vector-map
|
||||||
make-string
|
make-string
|
||||||
string
|
string
|
||||||
string-copy
|
string-copy
|
||||||
|
@ -54,10 +55,7 @@
|
||||||
string-fill!
|
string-fill!
|
||||||
string->list
|
string->list
|
||||||
string->vector
|
string->vector
|
||||||
; TODO:
|
string-map
|
||||||
;string-upcase
|
|
||||||
;string-downcase
|
|
||||||
;string-foldcase
|
|
||||||
make-parameter
|
make-parameter
|
||||||
current-output-port
|
current-output-port
|
||||||
current-input-port
|
current-input-port
|
||||||
|
@ -224,7 +222,6 @@
|
||||||
(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 (string->list str . opts)
|
(define (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))
|
||||||
|
@ -267,6 +264,10 @@
|
||||||
(string-set! str i fill)
|
(string-set! str i fill)
|
||||||
(loop (+ i 1)))))))
|
(loop (+ i 1)))))))
|
||||||
(loop start)))
|
(loop start)))
|
||||||
|
(define (string-map func str)
|
||||||
|
(list->string (map func (string->list str))))
|
||||||
|
(define (vector-map func vec)
|
||||||
|
(list->vector (map func (vector->list vec))))
|
||||||
(define (vector-append . vecs)
|
(define (vector-append . vecs)
|
||||||
(list->vector
|
(list->vector
|
||||||
(apply append (map vector->list vecs))))
|
(apply append (map vector->list vecs))))
|
||||||
|
|
|
@ -8,6 +8,10 @@
|
||||||
char-upper-case?
|
char-upper-case?
|
||||||
char-whitespace?
|
char-whitespace?
|
||||||
digit-value
|
digit-value
|
||||||
|
string-upcase
|
||||||
|
string-downcase
|
||||||
|
; TODO:
|
||||||
|
;string-foldcase
|
||||||
)
|
)
|
||||||
(import (scheme base))
|
(import (scheme base))
|
||||||
(begin
|
(begin
|
||||||
|
@ -35,5 +39,6 @@
|
||||||
(if (char-numeric? c)
|
(if (char-numeric? c)
|
||||||
(- (char->integer c) (char->integer #\0))
|
(- (char->integer c) (char->integer #\0))
|
||||||
#f))
|
#f))
|
||||||
|
(define (string-upcase str) (string-map char-upcase str))
|
||||||
|
(define (string-downcase str) (string-map char-downcase str))
|
||||||
))
|
))
|
||||||
|
|
Loading…
Add table
Reference in a new issue