On Mon, Nov 16, 2015 at 5:24 PM, David Nalesnik <david.nales...@gmail.com> wrote:
> Hi Simon, > > On Sun, Nov 15, 2015 at 12:53 PM, Simon Albrecht <simon.albre...@mail.de> > wrote: > >> Hello, >> >> The subject certainly seems cryptic – it’s difficult to summarize, but an >> example will make it clear immediately. >> I want to write a scheme procedure, which takes a pair like #'(3 . 7) and >> returns a list with all the numbers in the range: #'(3 4 5 6 7) >> How is this done most easily? >> >> > Well, if the numbers are ascending you could do something like: > > (define (expand-interval arg) > (iota (- (1+ (cdr arg)) (car arg)) (car arg))) > > (display (expand-interval '(3 . 7))) > > If not, something like this would work: > (define (expand-interval arg) (let ((step (if (> (car arg) (cdr arg)) -1 1))) (iota (1+ (abs (- (cdr arg) (car arg)))) (car arg) step))) --David
_______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user