Hi again,
> data Age = Age Int
> data Names = Names [String]
> data Person = Person (Age,Names)
>
> can be used to represent the details of a person, but the "essential
> type" corresponding to Person, is
>
> (Int,[String])
In Haskell, at least, this is not entirely true. When you say
On Wed, 2002-08-21 at 17:50, Dylan Thurston wrote:
> This is the same as one way of representing search trees, called a
> "trie". Two representations in Haskell are:
>
> > data Trie a = Trie [(a, Trie a)]
I touched on the following in my response to Hal Daume's email, but it's
probably worth as
Hi,
> On Wed, 2002-08-21 at 16:52, Hal Daume III wrote:
> > I would consider using a prefix trie. Unfortunately, such a structure is
> > not built in to Haskell.
>
> Thanks for this! It seems that this kind of data structure is what I
> am looking for.
Excellent.
> [(a, (Bool, *))
On Wed, 2002-08-21 at 16:52, Hal Daume III wrote:
> I would consider using a prefix trie. Unfortunately, such a structure is
> not built in to Haskell.
Thanks for this! It seems that this kind of data structure is what I
am looking for.
[begin aside]
It seems a pity that one needs to give t
On Wed, Aug 21, 2002 at 04:44:03PM +0930, Dr Mark H Phillips wrote:
> ...
> I would like to represent this structure in Haskell, but
> am not sure quite the best way of doing it. (I am relatively
> new to Haskell.) I think I want to do something like:
>
> [
> [(2,5),[(1,3),[(2,0)]],
>[
On Wed, Aug 21, 2002 at 04:44:03PM +0930, Dr Mark H Phillips wrote:
>
> I would like to represent this structure in Haskell, but
> am not sure quite the best way of doing it. (I am relatively
> new to Haskell.) I think I want to do something like:
>
> [
> [(2,5),[(1,3),[(2,0)]],
>[(1,
I would consider using a prefix trie. Unfortunately, such a structure is
not built in to Haskell. The data structure basically contains a root; at
the root you look up the first element, which gives you a new trie which
represents all of the elements which begin with that initial element. If
th
At 2002-08-21 01:14, Dr Mark H Phillips wrote:
>But what is the best way to represent this in Haskell? (Clearly
>I can't do exactly this, because Haskell requires all list elements
>to be of the same type.)
Create a new type that can allow either a pair or a list of pairs, and
use a list of th
Hi,
Consider the following data structure, effectively
of type [[(Int,Int)]]:
(2,5) (1,3) (2,0)
(2,5) (1,2) (1,1) (1,0)
(2,5) (3,1)
(1,5) (2,4) (2,0)
(1,5) (1,4) (1,3) (1,1) (1,0)
(1,5) (1,4) (2,2) (1,0)
(1,5) (1,4) (1,2) (2,1)
(1,5) (2,3) (1,2) (1,0)
(1,5) (2,3) (2,1)
(1,5) (1,3) (2,2) (1,1)
(1