mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-15 08:47: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); }
|
dispatch(argc.value, (function_type)dispatch_string_91append, cont, cont, args); }
|
||||||
void _string_91_125list(object cont, object args) {
|
void _string_91_125list(object cont, object args) {
|
||||||
string2list(lst, car(args));
|
string2list(lst, car(args));
|
||||||
return_funcall1(cont, &lst);}
|
return_funcall1(cont, lst);}
|
||||||
void _make_91vector(object cont, object args) {
|
void _make_91vector(object cont, object args) {
|
||||||
integer_type argc = Cyc_length(args);
|
integer_type argc = Cyc_length(args);
|
||||||
if (argc.value >= 2) {
|
if (argc.value >= 2) {
|
||||||
|
|
|
@ -40,8 +40,11 @@
|
||||||
Cyc-obj=?
|
Cyc-obj=?
|
||||||
make-string
|
make-string
|
||||||
vector
|
vector
|
||||||
|
vector-append
|
||||||
|
vector-copy
|
||||||
vector->list
|
vector->list
|
||||||
vector->string
|
vector->string
|
||||||
|
string->vector
|
||||||
error
|
error
|
||||||
raise
|
raise
|
||||||
raise-continuable
|
raise-continuable
|
||||||
|
@ -163,11 +166,28 @@
|
||||||
(cons (vector-ref vec i) lst))))))
|
(cons (vector-ref vec i) lst))))))
|
||||||
(loop start '())))
|
(loop start '())))
|
||||||
(define (vector->string vec . opts)
|
(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)
|
(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)
|
(define (boolean=? b1 b2 . bs)
|
||||||
(Cyc-obj=? boolean? b1 (cons 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)))
|
(write `(read ,@(list 1 2 3)))
|
||||||
;`(read ,
|
;`(read ,
|
||||||
(write (make-vector 4 #t))
|
(write (make-vector 4 #t))
|
||||||
|
(write (string->list "abc"))
|
||||||
|
|
Loading…
Add table
Reference in a new issue