Lukas-Fabian Moser <[email protected]> writes:

> Here is an improved version:
>
>
> \version "2.19.44"
>
> #(define (nth n l)
>   (if (or (> n (length l)) (< n 0))
>     (error "Index out of bounds.")
>     (if (eq? n 0)
>       (car l)
>       (nth (- n 1) (cdr l)))))

Seriously?

#(define (nth n l) (list-ref l n))

Which has the advantage of _not_ being O(n^2) because you check
(length l) (which is O(n)) in every iteration.

-- 
David Kastrup

_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to