Re: [Haskell-cafe] Re: Math questions

2010-05-28 Thread Mujtaba Boori
*
sure I did enjoy the discussion here Yitzchak Gale.  I have already
submitted several questions ,and you guys were very helpful. However , I am
not sure how I will use Haskell other than my Haskell course that has just
finished.

*
On 28 May 2010 14:52, Ivan Lazar Miljenovic wrote:

> Yitzchak Gale  writes:
>
> > My "for" function was indeed "flip map". Perhaps it's not
> > in any library, but it's often seen on the #haskell IRC
> > channel. :)
>
> Hmmm, I had never heard of this but going back through my logs I do
> indeed find nornagon, jethr0 and jmcarthur all either stating this
> definition or advocating it.  Alternate definitions that I found
> include:
>
> * pam (ski)
>
> * -<< (vixey)
>
> --
> Ivan Lazar Miljenovic
> ivan.miljeno...@gmail.com
> IvanMiljenovic.wordpress.com
>



-- 
Mujtaba Ali Alboori
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Math questions

2010-05-27 Thread Mujtaba Boori
*Pete Chown and Dan Doel. Thank you for your solution. I actually It was not
homework . It was just a a past exam question trying to answer . *
**but your solution is very long , so I don't think he wants answer this
long in the exams. I think this answer agree100 f g = map f xs == map g xs
where xs = [1..100] from  Richard O'Keefe
is do the job.

**Anyway , your solution help understand more about Haskell not only this
question . Many thanks to you guys.

On 27 May 2010 02:04, Dan Doel  wrote:

> On Wednesday 26 May 2010 5:38:57 pm Pete Chown wrote:
> > test :: (Eq a) => (Int -> a) -> (Int -> a) -> Bool
> > test f1 f2 = unsafePerformIO $ do
> >  goodSoFar <- newIORef True
> >  forLoop 1 100 $ \i ->
> >when (f1 i /= f2 i) $ writeIORef goodSoFar False
> >  readIORef goodSoFar
>
> The problem with this algorithm is that it needlessly tests f1 against f2
> for
> all i, even when a non-matching value has has already been found. Using the
> power of call-with-current-continuation, I have constructed an algorithm
> that
> lacks this deficiency:
>
>import Control.Monad.Cont
>
>test f g = flip runCont id . callCC $ \escape ->
>  do forM_ [1..100] $ \n ->
>   when (f n /= g n) $
> escape False
> return True
>
> This should perform almost 75% less work in the testFunc1 case! It
> certainly
> feels much snappier.
>
> -- Dan
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
Mujtaba Ali Alboori
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Math questions

2010-05-25 Thread Mujtaba Boori
Thank you all you , that is really impressive .


I will read your response carefully , and  I think this it is enough to
understand it.

On 25 May 2010 23:43, Daniel Fischer  wrote:

> On Tuesday 25 May 2010 23:47:30, Mujtaba Boori wrote:
> > Hello
> > I am try to solve this equation
> >
> > Define a higher order function  that tests whether two functions , both
> > defined on integers , coincide for all integers between 1 and 100
> >
> >  how can I solve this ?
> > is there any thing in Haskell library to solve this kind ?
>
> Sure. Lots of things to do it in different ways. All boil down to
> - for each integer from 1 to 100
> - check whether f i == g i
>
> Look at
>
> http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Prelude.html
> , there are  useful functions for this. You will probably want to use 'and'
> or 'all'.
>
>


-- 
Mujtaba Ali Alboori
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Math questions

2010-05-25 Thread Mujtaba Boori
Hello
I am try to solve this equation

Define a higher order function  that tests whether two functions , both
defined on integers , coincide for all integers between 1 and 100

 how can I solve this ?
is there any thing in Haskell library to solve this kind ?

-- 
Mujtaba Ali Alboori
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] newbie question how to pass data

2010-04-20 Thread Mujtaba Boori
Great job Stephen.
Thank for explaining . I got it to work.


On Tue, Apr 20, 2010 at 9:21 AM, Stephen Tetley wrote:

> Hi
>
> If you are working with characteristic functions (Point -> Bool or
> Point -> Colour...) the common way to do this is to manufacture a Num
> instance for functions. This gives you syntax overloading of the (+,
> -, *) operators. Similarly you might want to overload (or have to
> overload) Floating, Fractional...
>
> Examples using this technique are Jerzy Karczmarczuk's Clastic, Conal
> Elliott's Vertigo, Tangible Values, Pan etc.
>
> To overload Num you have to define Show and Eq instances for functions
> as well. Something along the lines of this is adequate:
>
> type CF = (Double,Double) -> Bool
>
> instance Show CF where
>  show _ = ""
>
> instance Eq CF where
>  (==) _ _ = error "No Eq on  Characteristic functions"
>
> instance Num CF where
>  f + g = \pt -> f pt + g pt
>  -- ...
>  negate f = \(x,y) -> f (negate x, negate y)
>
>  -- ... rest follows this pattern, Floating, Fractional similar
>
> If you characteristic function is Point -> Bool then you also need a
> Num instance for Bool.
>
> All that said, I think your formulation of func above is slightly
> wrong to fit this style. Its forming a function (-> Point) "to point"
> rather than a characteristic function Point -> Bool.
>
> Best wishes
>
> Stephen
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
Mujtaba Ali Alboori
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] newbie question how to pass data

2010-04-19 Thread Mujtaba Boori
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 wrote:

> 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 > ozgurak...@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 ><mailto:mujtaba.bo...@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
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] newbie question how to pass data

2010-04-19 Thread Mujtaba Boori
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  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
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> >
>
>
>
> --
> Ozgur Akgun
>



-- 
Mujtaba Ali Alboori
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] newbie question how to pass data

2010-04-19 Thread Mujtaba Boori
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
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: help with Haskell programming

2010-04-18 Thread Mujtaba Boori
Thanks a lot guys you were really helpful

func f1 f2 x = (f1 x) || (f2 x) is working for me



On Sun, Apr 18, 2010 at 6:27 PM, Thomas Davie  wrote:

> To do this, you need not just fmap (composition), but also ap, or the
> combined form, liftA2:
>
> func = liftA2 (||)
>
> Bob
>
> On 18 Apr 2010, at 18:21, Keith Sheppard wrote:
>
> > Using composition can be tricky with more than one arg. I just want to
> > be sure you're not really looking for something like:
> >
> >> func :: (a -> Bool) -> (b -> Bool) -> (a -> b -> Bool)
> >
> > keeping with your given type I think you're looking for something like:
> >
> >> func f1 f2 x = (f1 x) || (f2 x)
> >
> > I'm sure there is a nice way to do this with function composition but
> > I still find composition less intuitive than explicit args in cases
> > like this.
> >
> > On Sun, Apr 18, 2010 at 1:00 PM, Mujtaba Boori 
> wrote:
> >> Thanks for helping me but I have another problem (sorry for asking) . I
> >> tried to figure it out .
> >> how about if I want to compare two kind with (&&) (||)  for
> >> func :: (a -> Bool) -> (a -> Bool) -> (a -> Bool)
> >>
> >> I tried some thing like
> >> func = ((||) .)
> >> This is the annoying part about Haskell . I can not understand
> composition .
> >>
> >> On Sun, Apr 18, 2010 at 4:35 PM, Mujtaba Boori  >
> >> wrote:
> >>>
> >>> Hello I am kinda newbie in Haskell you can help help me with some
> >>> programming
> >>> I am trying to make function like for example
> >>> func :: (a -> Bool) -> (a -> Bool)
> >>> this function make calculation  and return bool . I want to be able to
> >>> make bool True when It is False and False when it is True while
> returning
> >>> the a.
> >>> Thank you
> >>> --
> >>> Mujtaba Ali Alboori
> >>
> >>
> >>
> >> --
> >> Mujtaba Ali Alboori
> >>
> >> ___
> >> Haskell-Cafe mailing list
> >> Haskell-Cafe@haskell.org
> >> http://www.haskell.org/mailman/listinfo/haskell-cafe
> >>
> >>
> >
> >
> >
> > --
> > keithsheppard.name
> > ___
> > Haskell-Cafe mailing list
> > Haskell-Cafe@haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>


-- 
Mujtaba Ali Alboori
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: help with Haskell programming

2010-04-18 Thread Mujtaba Boori
Thanks for helping me but I have another problem (sorry for asking) . I
tried to figure it out .

how about if I want to compare two kind with (&&) (||)  for

func :: (a -> Bool) -> (a -> Bool) -> (a -> Bool)

I tried some thing like

func = ((||) .)

This is the annoying part about Haskell . I can not understand composition .


On Sun, Apr 18, 2010 at 4:35 PM, Mujtaba Boori wrote:

> Hello I am kinda newbie in Haskell you can help help me with some
> programming
>
> I am trying to make function like for example
>
> func :: (a -> Bool) -> (a -> Bool)
>
> this function make calculation  and return bool . I want to be able to make
> bool True when It is False and False when it is True while returning the a.
>
> Thank you
>
> --
> Mujtaba Ali Alboori
>



-- 
Mujtaba Ali Alboori
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] help with Haskell programming

2010-04-18 Thread Mujtaba Boori
Hello I am kinda newbie in Haskell you can help help me with some
programming

I am trying to make function like for example

func :: (a -> Bool) -> (a -> Bool)

this function make calculation  and return bool . I want to be able to make
bool True when It is False and False when it is True while returning the a.

Thank you

-- 
Mujtaba Ali Alboori
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] "Improve Cabal's test support" for Google summer of code

2010-03-23 Thread Mujtaba Boori
Hello

I'm thinking of project for my google proposal . I found "improve Cabal's
test support' is really interesting .I have a decent knowledge about Haskell
programming and testing methods . I was wondering if this project is
suitable for me and what skill I required to have. I would be very thankful
if you give me advice for resources to look and understand it.



Thank you

-- 
Mujtaba Ali Alboori
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Google summer of code idea.

2010-03-21 Thread Mujtaba Boori
Hello

I would like to discuss my idea for google summer of code.  I'm an active
Haskell programmer . I have read the idea list . I think Improve Cabal's
test support really suit my ability of haskell. I would like to give me
advice about my idea . and how to improve my proposal . Thank you.

-- 
Mujtaba Ali Alboori
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe