I want to access a n-dimensional vector but somehow (empty? '()) keeps returning false.
;; access n dimensional vectors
;; (access-nd vector a-list-of-numbers) -> element
;; (access-nd (vector (vector 'x 'y) 'a 'b)) 0 1 ) -> x
(define (access-nd avector . alist)
(cond
((and (not(empty? alist)) (vector? avector))
(vector-ref (access-nd avector (rest alist)) (first alist)))
(else avector)))
Please Help.
Edit: CORRECTED CODE
(define (access-nd avector . alist)
(cond
((and (not(empty? alist)) (vector? avector))
(apply access-nd (vector-ref avector (first alist)) (rest alist)))
(else avector)))