> >Let me just remind people what the LML arrays does:
> >
> >example:
> > lmlarray 1 3 f list =
> > array [ 1:= f [ x | (1,x) <- list],
> > 2:= f [ x | (2,x) <- list],
> > 3:= f [ x | (3,x) <- list]
> > ]
> >where array is like the ordinary Haskell array constructor function.
> > ...
> >It seems to me that it is a bit more general to apply f to the entire
> >list accumulated at each index, rather than as an operator for foldr.
>
> If you want the list you can supply (:) and []. If not, you supply the
> operations, .....[ ]
>
This is of course a matter of taste, but I think that in some cases it is a
bit clumsier:
lmlarray l u (take 2) list
does seem simpler than, say
amap (take 2) (lmlarray' l u (:) list).
(I don't know how to express take 2 as an operator for foldr).
Also, in LML there is only one array constructor function, lmlarray
(simply called array in LML), so an 'ordinary' array is obtained by
lmlarray l u (\[ x ].x) list
(LML has . instead of -> ). Note that the pattern [ x ] in the function
forces the evaluation of the entire list and its indices, because,
intuitively, it has to be checked that there is no more than one element for
each index.
> .... and the intermediate list never gets built.
Yes, there is that.
-- Thomas