recursion - Trying to reverse a list in Scheme -


be forewarned: homework problem. i'm trying write scheme function reverses list. '(1 2 3) becomes '(3 2 1), etc. i'm not allowed use predefined function this.

am on right track wrote here?

;myreverse (define (myreverse list)     (if (null? list) '()         (append (myreverse(cdr list)) car list))) 

thanks!

well, using list name going odd, since scheme lisp-1. call lst instead.

think can foldl, cons, '(), , lst.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -