|
From: | David Nalesnik |
Subject: | Re: Scheme question: convert a range |
Date: | Mon, 16 Nov 2015 17:33:28 -0600 |
Hi Simon,On Sun, Nov 15, 2015 at 12:53 PM, Simon Albrecht <address@hidden> 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:
[Prev in Thread] | Current Thread | [Next in Thread] |