[squeak-dev] converting lists of integers and ranges of integers
from a string
Tony Garnock-Jones
tonyg at ccs.neu.edu
Mon Jun 6 12:48:02 UTC 2011
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
More information about the Squeak-dev
mailing list
|