[m-dev.] For review: minor additions to list.m and string.m

schachte at cs.mu.OZ.AU schachte at cs.mu.OZ.AU
Fri Sep 8 10:49:42 AEDT 2000


On  7 Sep, Ralph Becket wrote:
> Estimated hours taken: 0.25
> 
> Small additions to list and string.

This looks good; I just have one comment:

> library/list.m:
> 	Added func ++/2 as a synonym for list__append/2.
> 	Added func '..'/1 to generate ascending/descending integer range
> lists.

Firstly, s/1/2/.

I'm not sure this is the best way to do descending sequences. This means
you can never generate an empty list.  Eg, I would find

	1..0 = []

more natural than

	1..0 = [1,0]

which your implementation will do.

I guess I don't find .. intuitive for descending sequences.  I think a
better way to handle them, and to generalize the whole thing while
you're at it, is to allow an increment.  I can see two ways to do this
and have it look pretty:

	10,9..1
or
	10..1 by -1

Unfortunately, the precedence of , will make the first pretty hopeless.
I think you could make the second one work by overloading '..'/2 to be
both int .. int = list(int) and int .. end_increment_spec = list(int)
where

	:- type end_increment_spec ---> int by int.

and add 'by' as in infix operator with tighter precedence than '..' . 


-- 
Peter Schachte                     The use of COBOL cripples the mind; its
mailto:schachte at cs.mu.OZ.AU        teaching should, therefore, be regarded
http://www.cs.mu.oz.au/~schachte/  as a criminal offense.
PGP: finger schachte at 128.250.37.3      -- E. W. Dijkstra 

--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list