(define l1 (list 1 2 3))
(define l2 (list 4 5 6))
(define (concatenar l1 l2)
(if (null? l1) l2
(cons (car l1) (concatenar (cdr l1) l2)))
)
My result be a list '(1 2 3 4 6 7 8 9)
but I want a vector to come out
I know what is done with this function: vector->list But I do not know how to implement it
Rename your existing procedure to concatenar-helper
and write a wrapper procedure:
(define (concatenar-helper l1 l2)
(if (null? l1)
l2
(cons (car l1) (concatenar-helper (cdr l1) l2))))
(define (concatenar l1 l2)
(list->vector (concatenar-helper l1 l2)))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.