[Haskell-beginners] Unit conversion
amindfv at gmail.com
Thu Mar 17 22:17:01 CET 2011
Is there a good way to easily convert between units?
For example, let's say I have a data type:
data Volumes = Teaspoon | Tablespoon | Slice | FluidOunces
... and I want to define an infix function '<+>', which adds together
amounts of food:
(1, Slice, cake) <+> (1, Volume Tablespoon, sugar) <+> (32, Volume
Which would return:
What is the most efficient way to define equivalency/conversion between
I remember an interesting method for celsius-farenheit conversion in
Higher-Order Perl, using function composition, but that was between only 2
units. I'd like something where I don't have to provide n^2 definitions.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners