lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Ambitus with shape notes


From: David Kastrup
Subject: Re: Ambitus with shape notes
Date: Fri, 25 Aug 2017 19:46:55 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Lukas-Fabian Moser <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]