[Haskell-cafe] empty Array?
josefs at cs.chalmers.se
Mon Oct 11 05:59:58 EDT 2004
> It is, of course, trivial to implement this for lists. I've run into
> a snag, however, when trying to implement this for Arrays (as in
> Data.Array) - I can't seem to find a way to represent an empty array,
> which makes implementing 'empty' and 'null' impossible. Suggestions?
Empty arrays can be achieved by having bounds where the lower bound is
greater than the upper bound. An example would be:
> empty = array (1,0) 
The function null would check the bounds to see if the lower bound is
greater than the upper bound.
More information about the Haskell-Cafe