[racket] please help to change vector to list

From: Yingjian Ma (yingjian.ma1955 at gmail.com)
Date: Thu Jun 2 02:45:18 EDT 2011


I have this code

(define test
  (lambda (x v)
    (define helper
      (lambda (ls)
          ((empty? ls) '())
          ((empty? (rest ls)) '())
          ((equal? (second ls) x) (cons (first ls) (helper (rest
          (else (helper (rest ls))))))
   (helper (vector->list v))))

When I run it with
> (test 'a #(b a c a))
it returns
'(b c)

Is there a way to use the list such as (test 'a '(b a c a))?  I tried to
delete vector->list from the last line of the code, but it did not work.

Thanks a lot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110601/7c1cd7e5/attachment.html>

Posted on the users mailing list.