[Haskell-cafe] newbie question how to pass data
Dan Weston
westondan at imageworks.com
Mon Apr 19 14:02:38 EDT 2010
First of all, your function
func (x,y) s dg =((x*(cos dg) - y*(sin dg)),(x*(sin dg) - y*(cos dg)))
does NOT work for type (Float -> Float), unless you mean that that is
the type of the unused parameter s. Also, your desired type ((Float ->
Float) -> Bool) itself looks suspicious. It must accept any function
(without something to apply it to) and arbitrarily return True or False.
How will you decide which? I suspect you need another parameter for this
function.
Second, on the off chance you are trying to calculate the position on a
circle scaled then rotated an angle dg from (x,y), that new position is
f (x,y) s dg = (s*(x*(cos dg) - y*(sin dg)),s*(x*(sin dg) + y*(cos dg)))
in which case you are missing the s and the last minus sign in your
formula should be a plus sign.
If so, this can be evaluated with greater clarity (and probably
accuracy) in polar coordinates:
g (x,y) s dg = (r * cos a, r * sin a)
where r = s * sqrt (x^2 + y^2)
a = atan2 y x + dg
Third, if you did not need the scale, I would use an underscore to make
that clear:
h (x,y) _ dg = (r * cos a, r * sin a)
where r = sqrt (x^2 + y^2)
a = atan2 y x + dg
That's all the observations I can make unless you describe the problem
more clearly. Sorry.
Dan
Mujtaba Boori wrote:
> sorry
>
> ok I am trying to make these calculation
>
> func (x,y) s dg =((x*(cos dg) - y*(sin dg)),(x*(sin dg) - y*(cos dg)))
>
> This work for type (Float -> Float)
>
> but how can make it work with ((Float -> Float) -> Bool)
>
> because my main function that I want use with. it takes (Float,Float)
> ->Bool) I need to return the same type ((Float,Float) ->Bool) so it
> could be used with other function.
>
>
> On Mon, Apr 19, 2010 at 5:54 PM, Ozgur Akgun <ozgurakgun at gmail.com
> <mailto:ozgurakgun at gmail.com>> wrote:
>
> Can you at least give an example of how you intend to use this "func"?
> Since you do not describe it's behaviour, it is very hard to make a
> useful
> comment (at least for me)
>
> Best,
>
> On 19 April 2010 16:54, Mujtaba Boori <mujtaba.boori at gmail.com
> <mailto:mujtaba.boori at gmail.com>> wrote:
> >
> > Hello
> > I am sorry for the silly question.
> >
> > I have a function as the following
> > func:: ((Float,Float) ->Bool) -> Float -> ((Float,Float) -> Bool)
> > I am trying to make calculation in this type ((Float,Float)
> ->Bool) with Float and then pass the information to ((Float,Float)
> -> Bool)
> >
> > Thank again appreciated.
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org <mailto:Haskell-Cafe at haskell.org>
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> >
>
>
>
> --
> Ozgur Akgun
>
>
>
>
> --
> Mujtaba Ali Alboori
>
More information about the Haskell-Cafe
mailing list