How overload operator in Haskell?
4 Jul
2003
4 Jul
'03
3:09 a.m.
I've learned haskell months, but I still can't understand the type system very well. I can only write: ----------------------------------- type Vector = [Double] vadd,vsub :: Vector->Vector->Vector v1 `vadd` v2 = zipWith (+) v1 v2 v1 `vsub` v2 = zipWith (-) v1 v2 svmul :: Double->Vector->Vector s `svmul` v = map (s*) v ------------------------------------ Tough it works, it is not convenient to use. How to create a Vector type and overload mathematical operators? Thanks for your help. Liu Junfeng liujf@softhome.net 2003-07-04
8456
Age (days ago)
8456
Last active (days ago)
0 comments
1 participants
participants (1)
-
Liu Junfeng