Re: [Haskell-cafe] The C Equiv of != in Haskell miscommunication thread

2007-05-30 Thread Albert Y. C. Lai

Roberto Zunino wrote:

I actually misread the first one as

Control.Monad.Fix.fix ((1:) . tail . scanl (+) 1)

which is quite nice too, although

map (2^) [0..]

would be much simpler! ;-)


We apply a lesson learned from my last derivation. The lesson was to 
look at s!!(n+1).


s = 1 : tail (scanl (+) 1 s)

s!!(n+1) = (1 : tail (scanl (+) 1 s))!!(n+1)
 = tail (scanl (+) 1 s) !! n
 = scanl (+) 1 s !! (n+1)
 = 1 + s!!0 + s!!1 + s!!2 + ... + s!!n

It turns out that we can generalize it a bit to

s!!n = 1 + s!!0 + ... + s!!(n-1)

since, in case n=0, it gives s!!0 = 1 + empty sum, which is still right.

But now plugging the equation of s!!n into that of s!!(n+1) gives

s!!(n+1) = 1 + s!!0 + s!!1 + s!!2 + ... s!!(n-1) + s!!n
 = s!!n + s!!n
 = 2 * s!!n

Together with s!!0 = 1, this explains why s!!n = 2^n.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The C Equiv of != in Haskell miscommunication thread

2007-05-30 Thread Roberto Zunino

Jason Dagit wrote:

On 5/28/07, Donald Bruce Stewart <[EMAIL PROTECTED]> wrote:

P.S. Have some cute code:

Control.Monad.Fix.fix ((1:) . scanl (+) 1)


Speaking of cute code, I'm fond of this:

map length . List.group . Control.Monad.Fix.fix $ show


Indeed, very nice examples!

I actually misread the first one as

Control.Monad.Fix.fix ((1:) . tail . scanl (+) 1)

which is quite nice too, although

map (2^) [0..]

would be much simpler! ;-)

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


Re: [Haskell-cafe] The C Equiv of != in Haskell miscommunication thread

2007-05-30 Thread Tomasz Zielonka
On Tue, May 29, 2007 at 06:40:05PM -0700, Jason Dagit wrote:
> Speaking of cute code, I'm fond of this:
> 
> map length . List.group . Control.Monad.Fix.fix $ show

"fix show" is cool in itself! :-)

Best regards
Tomek
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The C Equiv of != in Haskell miscommunication thread

2007-05-30 Thread Vincent Kraeutler
i would just like to say thank you for all the extensive replies. after
fiddling with them for an afternoon i'm positive i grokked the concept.

it's just too bad the nice wrapper concept from [1] does not seem to be
directly applicable to fix in haskell, since they require untyped
side-effects

anyhow, this has been very instructive.
thanks again!
v.

[1] http://citeseer.ist.psu.edu/mcadams01practical.html

Jason Dagit wrote:
> On 5/28/07, Donald Bruce Stewart <[EMAIL PROTECTED]> wrote:
>> This thread should end, guys. It is inappropriate for the Haskell lists,
>> and appears to have been a simple misunderstanding anyway.
>>
>> Thanks everyone. Please stay friendly!
>>
>> -- Don
>>
>> P.S. Have some cute code:
>>
>> Control.Monad.Fix.fix ((1:) . scanl (+) 1)
>
> Speaking of cute code, I'm fond of this:
>
> map length . List.group . Control.Monad.Fix.fix $ show
>
> And other (longer) variations which generate only powers of two.  It's
> a great conversation starter for teaching about fix.
>
> Jason
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>




signature.asc
Description: OpenPGP digital signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The C Equiv of != in Haskell miscommunication thread

2007-05-29 Thread Jason Dagit

On 5/28/07, Donald Bruce Stewart <[EMAIL PROTECTED]> wrote:

This thread should end, guys. It is inappropriate for the Haskell lists,
and appears to have been a simple misunderstanding anyway.

Thanks everyone. Please stay friendly!

-- Don

P.S. Have some cute code:

Control.Monad.Fix.fix ((1:) . scanl (+) 1)


Speaking of cute code, I'm fond of this:

map length . List.group . Control.Monad.Fix.fix $ show

And other (longer) variations which generate only powers of two.  It's
a great conversation starter for teaching about fix.

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


Re: [Haskell-cafe] The C Equiv of != in Haskell

2007-05-29 Thread Tomasz Zielonka
On Tue, May 29, 2007 at 11:20:27AM +0100, David House wrote:
> On 29/05/07, Daniel McAllansmith <[EMAIL PROTECTED]> wrote:
> >Just in case there was some sort of miscommunication, the actual answer to
> >your question is (/=) :: a -> a -> Bool, as Neil said.
> 
> Almost, (/=) :: Eq a => a -> a.

Almost again!

(/=) :: Eq a => a -> a -> Bool

Best regards
Tomek
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The C Equiv of != in Haskell

2007-05-29 Thread David House

On 29/05/07, Antti-Juhani Kaijanaho <[EMAIL PROTECTED]> wrote:

Well, not quite :)  You forgot "-> Bool" at the end :)


Ha! Sorry, what a lovely ironic typo. :)

--
-David House, [EMAIL PROTECTED]
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The C Equiv of != in Haskell

2007-05-29 Thread Antti-Juhani Kaijanaho
On Tue, May 29, 2007 at 11:20:27AM +0100, David House wrote:
> Almost, (/=) :: Eq a => a -> a.

Well, not quite :)  You forgot "-> Bool" at the end :)

> (Just for completeness.)

Exactly :)

-- 
Antti-Juhani Kaijanaho, Jyväskylä
http://antti-juhani.kaijanaho.fi/newblog/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The C Equiv of != in Haskell

2007-05-29 Thread David House

On 29/05/07, Daniel McAllansmith <[EMAIL PROTECTED]> wrote:

Just in case there was some sort of miscommunication, the actual answer to
your question is (/=) :: a -> a -> Bool, as Neil said.


Almost, (/=) :: Eq a => a -> a.

(Just for completeness.)

--
-David House, [EMAIL PROTECTED]
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The C Equiv of != in Haskell miscommunication thread

2007-05-28 Thread Donald Bruce Stewart
kahl:
>  > 
>  > P.S. Have some cute code:
>  > 
>  > Control.Monad.Fix.fix ((1:) . scanl (+) 1)
> 
> 
> Cute!
> 
> But what an un-cute qualified name:
> 
> :t Control.Monad.Fix.fix
> Control.Monad.Fix.fix :: (a -> a) -> a
> 
> 
> Has nothing to do with monads,
> and would perhaps be considered as ``out of Control'' in any case...
> 

I see it has moved into Data.Function,

module Data.Function
( -- * "Prelude" re-exports
id, const, (.), flip, ($)
-- * Other combinators
, fix
, on
  ) where

A much better place.

-- Don

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


Re: [Haskell-cafe] The C Equiv of != in Haskell miscommunication thread

2007-05-28 Thread kahl
 > 
 > P.S. Have some cute code:
 > 
 > Control.Monad.Fix.fix ((1:) . scanl (+) 1)


Cute!

But what an un-cute qualified name:

:t Control.Monad.Fix.fix
Control.Monad.Fix.fix :: (a -> a) -> a


Has nothing to do with monads,
and would perhaps be considered as ``out of Control'' in any case...

;-)


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


Re: [Haskell-cafe] The C Equiv of != in Haskell (Apologies)

2007-05-28 Thread Alfonso Acosta

On 5/29/07, PR Stanley <[EMAIL PROTECTED]> wrote:

Yet, you seem to be desperate to keep the thread alive.


As long as I'm personally attacked. But whatever, let's forget about
it, you already said it's been a bad day.

End of flamebait
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The C Equiv of != in Haskell miscommunication thread

2007-05-28 Thread Donald Bruce Stewart
This thread should end, guys. It is inappropriate for the Haskell lists,
and appears to have been a simple misunderstanding anyway.

Thanks everyone. Please stay friendly!

-- Don

P.S. Have some cute code:

Control.Monad.Fix.fix ((1:) . scanl (+) 1)

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


Re: [Haskell-cafe] The C Equiv of != in Haskell (Apologies)

2007-05-28 Thread PR Stanley



However, I don't think these other individuals had any business
poking their hooters into this.


If you don't want other individuals "poking their hooters" in what you
write, I recommend you to avoid sending open questions to public
mailing lists.
yes, I was indeed referring to you and your large beak over which you 
clearly have no control. Nobody invited you to this discussion and as 
you can see I have already apologized to Neil for the 
misunderstanding. Yet, you seem to be desperate to keep the thread alive.


Uh, save me from the ... 


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


Re: [Haskell-cafe] The C Equiv of != in Haskell

2007-05-28 Thread PR Stanley

Thank you Neil, again I'm sorry for getting the wrong end of the stick.
Cheers
Paul
At 02:50 29/05/2007, you wrote:

Hi Paul

Sorry if you interpreted my answer as a symbol, I never use smilies so
didn't even consider that people may see it in another light!

Thanks

Neil


On 5/29/07, PR Stanley <[EMAIL PROTECTED]> wrote:


> > >Hi
> > >
> > >>What is the C equivalent of the inequality operator in Haskell?
> > >
> > >/=
> > >
> > >You can answer these sorts of questions yourself using Hoogle:
> >
> > And what makes you think I haven't tried Google already?
> > Unlike you I only write to the list when I have a legitimate 
reason to do

> > so.
>
>Just in case there was some sort of miscommunication, the actual answer to
>your question is (/=) :: a -> a -> Bool, as Neil said.
>
>The /= wasn't some sort of frowny, quit-wasting-my-time emoticon.
>___
Thank you, Dan.
Regards
Paul

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


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


Re: [Haskell-cafe] The C Equiv of != in Haskell (Apologies)

2007-05-28 Thread Alfonso Acosta

On 5/29/07, PR Stanley <[EMAIL PROTECTED]> wrote:

However, I don't think these other individuals had any business
poking their hooters into this.


If you don't want other individuals "poking their hooters" in what you
write, I recommend you to avoid sending open questions to public
mailing lists.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The C Equiv of != in Haskell

2007-05-28 Thread PR Stanley

At 03:02 29/05/2007, you wrote:

On 5/29/07, PR Stanley <[EMAIL PROTECTED]> wrote:

What is this, the Haskell Cafe Gang?


Maybe. Moreover this list is not a prepaid service in which you can
unpolitely _demand_ answers.

You got your question answered still complain ... I don't get it.
Yes, the question has been answered but you still feel the need to 
keep the thread alive, hmm, you're right, it is very strange behaviour indeed.


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


Re: [Haskell-cafe] The C Equiv of != in Haskell (Apologies)

2007-05-28 Thread PR Stanley



Hi


>You can answer these sorts of questions yourself using Hoogle:
And what makes you think I haven't tried Google already?


Hoogle, starting with 'H'. Follow the link I gave you, which is a
search engine for Haskell functions, by type and name. If you search
for "a -> a -> Bool" (a likely type that the != would have) then
Hoogle gives you an answer.


Unlike you I only write to the list when I have a legitimate reason to do so.


I am not suggesting you have no legitimate reason, just trying to help
you find the information you need quicker in future. I was in no way
trying to suggest you shouldn't have posted - its a fair question
given its a different choice to most other languages.

Thanks

Neil

Thank you,Neil. I apologise for my sharp response. It's been a long day.
However, I don't think these other individuals had any business 
poking their hooters into this.

All the best,
Paul 


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


Re: [Haskell-cafe] The C Equiv of != in Haskell

2007-05-28 Thread Alfonso Acosta

On 5/29/07, PR Stanley <[EMAIL PROTECTED]> wrote:

What is this, the Haskell Cafe Gang?


Maybe. Moreover this list is not a prepaid service in which you can
unpolitely _demand_ answers.

You got your question answered still complain ... I don't get it.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The C Equiv of != in Haskell

2007-05-28 Thread PR Stanley

At 02:27 29/05/2007, you wrote:

PR Stanley wrote:



Hi


What is the C equivalent of the inequality operator in Haskell?


/=

You can answer these sorts of questions yourself using Hoogle:

And what makes you think I haven't tried Google already?
Unlike you I only write to the list when I have a legitimate reason to do so.


Apparently, unlike him, you don't read the emails.  He answered your 
question, gave you one way of answering all such future question 
(note Hoogle /= Google), and finally, there are certainly other 
places you could look before writing to the list that would answer 
your question, e.g. the Report.

and you can mind your own damn business.
What is this, the Haskell Cafe Gang?

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


Re: [Haskell-cafe] The C Equiv of != in Haskell

2007-05-28 Thread PR Stanley



> >Hi
> >
> >>What is the C equivalent of the inequality operator in Haskell?
> >
> >/=
> >
> >You can answer these sorts of questions yourself using Hoogle:
>
> And what makes you think I haven't tried Google already?
> Unlike you I only write to the list when I have a legitimate reason to do
> so.

Just in case there was some sort of miscommunication, the actual answer to
your question is (/=) :: a -> a -> Bool, as Neil said.

The /= wasn't some sort of frowny, quit-wasting-my-time emoticon.
___

Thank you, Dan.
Regards
Paul

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


Re: [Haskell-cafe] The C Equiv of != in Haskell

2007-05-28 Thread PR Stanley

At 02:26 29/05/2007, you wrote:

PR Stanley wrote:
>
>> Hi
>>
>>> What is the C equivalent of the inequality operator in Haskell?
>>
>> /=
>>
>> You can answer these sorts of questions yourself using Hoogle:
> And what makes you think I haven't tried Google already?
> Unlike you I only write to the list when I have a legitimate reason to
> do so.
The respondent said HHHoogle, not Google, and rightly so.
Did you take a look at the given link? Here it is again
http://www.haskell.org/hoogle/?q=a%20-%3E%20a%20-%3E%20Bool

Hold onto that jerky knee!
It's a sort of natural reaction to self-righteous jerks.
Of course, a simple reply to the initial question would have been far 
too convenient. 


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


Re: [Haskell-cafe] The C Equiv of != in Haskell

2007-05-28 Thread Daniel McAllansmith
On Tuesday 29 May 2007 13:20, PR Stanley wrote:
> >Hi
> >
> >>What is the C equivalent of the inequality operator in Haskell?
> >
> >/=
> >
> >You can answer these sorts of questions yourself using Hoogle:
>
> And what makes you think I haven't tried Google already?
> Unlike you I only write to the list when I have a legitimate reason to do
> so.

Just in case there was some sort of miscommunication, the actual answer to 
your question is (/=) :: a -> a -> Bool, as Neil said.

The /= wasn't some sort of frowny, quit-wasting-my-time emoticon.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The C Equiv of != in Haskell

2007-05-28 Thread Derek Elkins

PR Stanley wrote:



Hi


What is the C equivalent of the inequality operator in Haskell?


/=

You can answer these sorts of questions yourself using Hoogle:

And what makes you think I haven't tried Google already?
Unlike you I only write to the list when I have a legitimate reason to 
do so.


Apparently, unlike him, you don't read the emails.  He answered your question, 
gave you one way of answering all such future question (note Hoogle /= Google), 
and finally, there are certainly other places you could look before writing to 
the list that would answer your question, e.g. the Report.

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


Re: [Haskell-cafe] The C Equiv of != in Haskell

2007-05-28 Thread Neil Mitchell

Hi


>You can answer these sorts of questions yourself using Hoogle:
And what makes you think I haven't tried Google already?


Hoogle, starting with 'H'. Follow the link I gave you, which is a
search engine for Haskell functions, by type and name. If you search
for "a -> a -> Bool" (a likely type that the != would have) then
Hoogle gives you an answer.


Unlike you I only write to the list when I have a legitimate reason to do so.


I am not suggesting you have no legitimate reason, just trying to help
you find the information you need quicker in future. I was in no way
trying to suggest you shouldn't have posted - its a fair question
given its a different choice to most other languages.

Thanks

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


Re: [Haskell-cafe] The C Equiv of != in Haskell

2007-05-28 Thread Tony Morris
PR Stanley wrote:
> 
>> Hi
>>
>>> What is the C equivalent of the inequality operator in Haskell?
>>
>> /=
>>
>> You can answer these sorts of questions yourself using Hoogle:
> And what makes you think I haven't tried Google already?
> Unlike you I only write to the list when I have a legitimate reason to
> do so.
> 
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 
> 

The respondent said HHHoogle, not Google, and rightly so.
Did you take a look at the given link? Here it is again
http://www.haskell.org/hoogle/?q=a%20-%3E%20a%20-%3E%20Bool

Hold onto that jerky knee!

Tony Morris
http://tmorris.net/



signature.asc
Description: OpenPGP digital signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The C Equiv of != in Haskell

2007-05-28 Thread PR Stanley



Hi


What is the C equivalent of the inequality operator in Haskell?


/=

You can answer these sorts of questions yourself using Hoogle:

And what makes you think I haven't tried Google already?
Unlike you I only write to the list when I have a legitimate reason to do so.

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


Re: [Haskell-cafe] The C Equiv of != in Haskell

2007-05-28 Thread Neil Mitchell

Hi


What is the C equivalent of the inequality operator in Haskell?


/=

You can answer these sorts of questions yourself using Hoogle:

http://www.haskell.org/hoogle/?q=a%20-%3E%20a%20-%3E%20Bool

Thanks

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


[Haskell-cafe] The C Equiv of != in Haskell

2007-05-28 Thread PR Stanley

Hi
What is the C equivalent of the inequality operator in Haskell?
Thanks
Paul

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