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
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
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.
More information about the Beginners