[squeak-dev] converting lists of integers and ranges of integers
from a string
Tom Rushworth
tom.b.rushworth at gmail.com
Mon Jun 6 14:33:28 UTC 2011
Use something else instead of the "-" for ranges, like ".." or ":".
E.g.
-9,-5..-3,-1..4,7,11..15
-9,-5:-3,-1:4,7,11:15
On 11/06/06 05:48, Tony Garnock-Jones wrote:
> On 2011-06-06 7:51 AM, Ralph Boland wrote:
>> If there is a conventional solution to this problem I would of course
>> like to know what it is and where
>> it is used.
>
> SML's syntax forbids use of the same operator in unary and binary
> contexts, so it distinguishes between unary minus and binary minus.
> SML's unary minus operator is tilde "~", so you could write:
>
> '~9,~5-~3,~1-4,7,11-15'
>
> for the problem example.
>
> Another option could be to use interval syntax:
>
> '-9 [-5 -3] [-1 4] 7 [11 15]'
>
> with or without commas.
>
> Regards,
> Tony
>
>
--
Tom Rushworth
More information about the Squeak-dev
mailing list
|