[Haskell-cafe] Learn You a Haskell for Great Good - a few doubts
Markus Läll
markus.l2ll at gmail.com
Fri Mar 4 17:45:13 CET 2011
Sorry, I didn't mean to answer you in particular. I meant to say that for
tuples you could (I think) have an enumeration over them without requiring
any component be bounded.
An example of type (Integer, Integer) you would have:
[(0,0) ..] = [(0,0) (0,1) (1,0) (0,2) (1,1) (2,0) ... ]
where the order can be visualized by taking diagonals of a table starting
from the upper left:
0 1 2 ..
0 (0,0) (0,1) (0,2)
1 (1,0) (1,1) (1,2)
2 (2,0) (2,1) (2,2)
..
Would this also have an uncomputable order type? At least for comparing
tuples you'd just:
lt :: (Integer,Integer) -> (Integer,Integer) -> Bool
(a,b) `lt` (c,d) = let
sum1 = (a + b)
sum2 = (c + d)
in if sum1 == sum2
then a < c
else sum1 < sum2
Implementing fromEnum looks like a bit harder problem..
--
Markus Läll
On Fri, Mar 4, 2011 at 5:12 AM, Daniel Fischer <
daniel.is.fischer at googlemail.com> wrote:
>
> On Friday 04 March 2011 03:24:34, Markus wrote:
> > What about having the order by diagonals, like:
> >
> > 0 1 3
> > 2 4
> > 5
> >
> > and have none of the pair be bounded?
> >
>
> I tacitly assumed product order (lexicographic order).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110304/e6a6c201/attachment.htm>
More information about the Haskell-Cafe
mailing list