[Haskell-beginners] Eg.
Mateusz Kowalczyk
fuuzetsu at fuuzetsu.co.uk
Sun Jan 19 12:24:17 UTC 2014
On 19/01/14 12:06, willie ekaputra wrote:
> Eg. how to make the translation formula ?
> u take a coordinate and multiply it with p Element R, so that it is
> translated , like 1, 3 to 2, 6 , I use a 2 as multiplicator , which is from
> real numbers.How to express this real number ?That is why " any number will
> just do ! "
> Regards , Wili.
>
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
Hi again,
A (limited precision) Real is sometimes known as a Double and that's
what it is in Haskell. So what you're asking is how to take an
arbitrary Double and translate your co-ordinate by it. Simply, you want
a function.
So if your co-ordinate is just a pair of two other Doubles (reals),
you can do:
type Coord = (Double, Double) -- Our co-ordinate
-- Function that takes a Double and Coord and translates the Coord by
-- the Double
translateCoord s (x, y) = (s * x, s * y)
You can then use it like: ‘translateCoord 2 (1, 3)’ to give you ‘(2, 6)’.
PS: It's much easier for us to follow if you keep your conversation in
a single thread.
--
Mateusz K.
More information about the Beginners
mailing list