Scheme hackers,
following simple code extract:

(define testlist (list 0 1 2 3 4 5 6 7))

(define (addlist i nr)
 (cons (list-ref testlist i) (if (= (+ i 1) nr) '() (addlist (+ i 1) nr)))
)

(display (addlist 0 3))

The procedure addlist returns all list elements up to the element >before< that whose index is given through the second argument. I. The source list is now defined globally. How can I pass it to the procedure "addlist" without carrying it along through all instances of the recursion? II. I assume also the index number ("nr") doesn't has to be passed to addlist every recursion stage. How to achieve this?

I'd be happy about any advice!

Cheers,
Michael






_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to