[m-dev.] for review: add a new pred to array.m

Peter Schachte schachte at cs.mu.OZ.AU
Wed Mar 31 10:57:11 AEST 1999


On Wed, Mar 31, 1999 at 10:21:21AM +1000, Thomas Charles Conway wrote:
> --- array.m	1999/03/22 08:08:40	1.52
> +++ array.m	1999/03/30 23:50:27
> +
> +array__map(Closure, OldArray, NewArray) :-
> +	( array__semidet_lookup(OldArray, 0, Elem0) ->
> +		array__size(OldArray, Size),
> +		call(Closure, Elem0, Elem),
> +		array__init(Size, Elem, NewArray0),
> +		array__map_2(0, Size, Closure, OldArray,
> +		NewArray0, NewArray)
> +	;
> +		array__make_empty_array(NewArray)
> +	).

Shouldn't that be

	array__map_2(1, Size, Closure, OldArray, NewArray0, NewArray)?

No point invoking the closure for the 0th element of the array twice!

-- 
Peter Schachte                     Any movement in history which attempts to
mailto:schachte at cs.mu.OZ.AU        perpetuate itself, becomes reactionary.
http://www.cs.mu.oz.au/~schachte/      -- Josip Broz Tito 
PGP: finger schachte at 128.250.37.3  



More information about the developers mailing list