On Fri, Nov 21, 2008 at 4:46 PM, Michael Käppler <[EMAIL PROTECTED]> wrote: > 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 think you should look into the srfi-1 library. Also, guile> (help list-head) `list-head' is a primitive procedure in the (guile) module. c snarfed from list.c:491 @deffn {Scheme Procedure} list-head lst k Copy the first @var{k} elements from @var{lst} into a new list, and return it. @end deffn Iwould probably write something like (define (take lst n) (define (helper lst acc n) (if (or (=? 0 n) (null? lst)) acc (helper (cdr lst) (cons lst acc) (1- n)))) (reverse (helper lst '() n))) -- Han-Wen Nienhuys - [EMAIL PROTECTED] - http://www.xs4all.nl/~hanwen
_______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel