[Haskell-beginners] represent data sturcture using function
Raeck chiu
raeck at msn.com
Mon Dec 29 00:04:28 EST 2008
Merry Christmas!
Hope everybody is enjoying the Christmas!
I am doing some readings and I found something seems to be interesting.
People sometime will try to represent a quantity-regard-only data structure
(such a order-regadless List) using functions instead of ta concrete data
structure (like the haskell build-in []), any particular reason for this?
For example,
> data Sex = Male | Female
> classA :: Sex -> Int
> classA Male = 100
> classA Female = 200
when I should prefer the above solution instead of using a concrete data structure
such as [] to represent the classA members?
It seems to be very difficult to change the number of Male or Female if a concrete data
structure is not used. Is it possible change the number of Male in classA when represent
classA using function?
Thank you very much!
Best wishes,
Raeck
_________________________________________________________________
It’s the same Hotmail®. If by “same” you mean up to 70% faster.
http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_broad1_122008
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20081229/78f7e2f7/attachment.htm
More information about the Beginners
mailing list