
Thanks Dan. Great help
but my problem has not solved yet
This doesn't work for type ((Float -> Float)->Bool)
to make it easier ignore the rotation and suppose I want just multiplay with
whatever (x ,y) and return the result to this type ((Float -> Float)->Bool)
note this type is shorten and replace by t
Type Point = (Float, Float)
Type Bitmap = Point -> Bool
so the function type actually
func :: Bitmap -> Float -> Bitmap
I want to take Bitmap do some calculation on Bitmap the return it
as Bitmap.
GHCi response for Dan method is this
Couldn't match expected type `Bitmap'
against inferred type `(a, b)'
so it is missing a Bool.
hopefully it is clear .
On Mon, Apr 19, 2010 at 7:02 PM, Dan Weston
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
> 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
mailto:mujtaba.boori@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@haskell.org mailto:Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe >
-- Ozgur Akgun
-- Mujtaba Ali Alboori
-- Mujtaba Ali Alboori