[plt-scheme] Fun with paren-shape

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Thu Jun 7 12:53:36 EDT 2007

Eli Barzilay skrev:
> On Jun  6, Jens Axel Søgaard wrote:
>> But - we can have both. The version below uses .. for "short"
>> intervals and "..." for "long" intervals. That is:
>>
>>    [1 .. 4]   => '(1 2 3)
>>    [1 ... 4]  => '(1 2 3 4)
> 
> This sounds like a classic bit that is impossible to remember without
> an open manual.

Well, It doesn't take long try them in the REPL. But you have
a point.

>> Ans sometimes you need a step:
>>
>>   [1 .. 7 2]   => '(1 3 5))
>>   [1 .. 8 2]   => '(1 3 5 7))
>>   [1 ... 7 2]  => '(1 3 5 7))
>>   [1 ... 8 2]  => '(1 3 5 7))
> 
> In Swindle I used `1 3 .. 7' which makes more sense for readability,
> but can be inconvenient (when you know the delta but not the first
> item).  I'd go with a `step' keyword here.

Good idea.

>>> What you've got above is more like [a .. b).  (I'm
>>> pretty partial to (iota 10 1) for this particular idiom, myself,
>>> though.)
>> Iota! Excellent idea. One could argue that (iota 5) is better
>> syntax than the below, but we can always remove it. I added
>> the following syntax
>>
>>    [5]      =>  (iota 5)     =>  (0 1 2 3 4)
>>    [5 3]    =>  (iota 5 3)   =>  (3 4 5 6 7)
>>    [5 3 2]  =>  (iota 5 3 2) =>  (3 5 7 9 11)
> 
> (Ugh...)

Yeah - that's got to go.

-- 
Jens Axel Søgaard





Posted on the users mailing list.