lilypond-user
[Top][All Lists]
Advanced

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

Re: Scheme question: convert a range


From: Thomas Morley
Subject: Re: Scheme question: convert a range
Date: Mon, 16 Nov 2015 22:20:45 +0100

2015-11-15 19:53 GMT+01:00 Simon Albrecht <address@hidden>:
> 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?
>
> TIA, Simon



Hi Simon,

(define (foo pair)
  (if (and (integer? (car pair)) (integer? (cdr pair)))
      (iota (1+ (interval-length pair)) (car pair) 1))
      #f)

(foo '(3 . 7))
--> (3 4 5 6 7)


HTH,
  Harm



reply via email to

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