mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-15 00:37:35 +02:00
Adding more vector functions
This commit is contained in:
parent
1edd3939a4
commit
a7fce12fdd
3 changed files with 26 additions and 5 deletions
|
@ -1136,7 +1136,7 @@ void _string_91append(object cont, object args) {
|
|||
dispatch(argc.value, (function_type)dispatch_string_91append, cont, cont, args); }
|
||||
void _string_91_125list(object cont, object args) {
|
||||
string2list(lst, car(args));
|
||||
return_funcall1(cont, &lst);}
|
||||
return_funcall1(cont, lst);}
|
||||
void _make_91vector(object cont, object args) {
|
||||
integer_type argc = Cyc_length(args);
|
||||
if (argc.value >= 2) {
|
||||
|
|
|
@ -40,8 +40,11 @@
|
|||
Cyc-obj=?
|
||||
make-string
|
||||
vector
|
||||
vector-append
|
||||
vector-copy
|
||||
vector->list
|
||||
vector->string
|
||||
string->vector
|
||||
error
|
||||
raise
|
||||
raise-continuable
|
||||
|
@ -163,11 +166,28 @@
|
|||
(cons (vector-ref vec i) lst))))))
|
||||
(loop start '())))
|
||||
(define (vector->string vec . opts)
|
||||
TODO
|
||||
)
|
||||
(let ((lst (apply vector->list (cons vec opts))))
|
||||
(list->string lst)))
|
||||
;; TODO: need to extend string->list to take optional start/end args,
|
||||
;; then modify this function to work with optional args, too
|
||||
(define (string->vector str . opts)
|
||||
TODO
|
||||
)
|
||||
(list->vector
|
||||
(string->list str)))
|
||||
(define (vector-append . vecs)
|
||||
vecs) ; TODO
|
||||
|
||||
(define (vector-copy vec . opts)
|
||||
(letrec ((len (vector-length vec))
|
||||
(start (if (> (length opts) 0) (car opts) 0))
|
||||
(end (if (> (length opts) 1) (cadr opts) len))
|
||||
(loop (lambda (i new-vec)
|
||||
(cond
|
||||
((= i end)
|
||||
new-vec)
|
||||
(else
|
||||
(vector-set! new-vec i (vector-ref vec i))
|
||||
(loop (+ i 1) new-vec))))))
|
||||
(loop start (make-vector (- end start) #f))))
|
||||
|
||||
(define (boolean=? b1 b2 . bs)
|
||||
(Cyc-obj=? boolean? b1 (cons b2 bs)))
|
||||
|
|
1
test.scm
1
test.scm
|
@ -6,3 +6,4 @@
|
|||
(write `(read ,@(list 1 2 3)))
|
||||
;`(read ,
|
||||
(write (make-vector 4 #t))
|
||||
(write (string->list "abc"))
|
||||
|
|
Loading…
Add table
Reference in a new issue