Re: [Haskell-cafe] Decision procedure for foldr/foldl/foldl'?

2011-11-22 Thread Jerzy Karczmarczuk
David Fox reacts to my criticism of his attitude towards the meaning of folds: I'm not trying to avoid learning the differences between the different folds, but I am looking for a mnemonic device that will allow me to proceed more quickly towards my goal. My ultimate goal is to write software,

Re: [Haskell-cafe] Decision procedure for foldr/foldl/foldl'?

2011-11-22 Thread David Fox
On Tue, Nov 22, 2011 at 5:04 AM, Jerzy Karczmarczuk jerzy.karczmarc...@unicaen.fr wrote: David Fox reacts to my criticism of his attitude towards the meaning of folds: I'm not trying to avoid learning the differences between the different folds, but I am looking for a mnemonic device that

Re: [Haskell-cafe] Decision procedure for foldr/foldl/foldl'?

2011-11-22 Thread Brandon Allbery
On Tue, Nov 22, 2011 at 09:10, David Fox dds...@gmail.com wrote: I think the other replies in this thread speak for themselves - i found them very helpful. That would be because they mostly back-doored around your stated intent. -- brandon s allbery

Re: [Haskell-cafe] Decision procedure for foldr/foldl/foldl'?

2011-11-21 Thread Yves Parès
I would say a good practice with folds (and maybe in Haskell in general) is that either all be strict or all be lazy. In the expression: foldXX f init list: Remember that foldr does: x `f` ( ... the accumulator ... ) and foldl: (... the accumulator ...) `f` x The accumulator has to match a

Re: [Haskell-cafe] Decision procedure for foldr/foldl/foldl'?

2011-11-21 Thread Jerzy Karczmarczuk
Yves Parès: if *f* is lazy in its second argument, then use foldr. Everything is lazy, you build a very small thunk since nothing is evaluated. In the rare cases where*f *is (also) lazy in its first argument, you can use foldl. ... I have the impression that this is not the most useful advice

Re: [Haskell-cafe] Decision procedure for foldr/foldl/foldl'?

2011-11-21 Thread David Fox
On Mon, Nov 21, 2011 at 4:44 AM, Jerzy Karczmarczuk jerzy.karczmarc...@unicaen.fr wrote: In general, sorry for the cynism, but when I read: There are times when I would like to find out which to use in the quickest way possible, rather than reading a long explanation of why each one behaves

[Haskell-cafe] Decision procedure for foldr/foldl/foldl'?

2011-11-20 Thread David Fox
Does anyone have a quick way to decide which of the fold functions to use in a given situation? There are times when I would like to find out which to use in the quickest way possible, rather than reading a long explanation of why each one behaves the way it does.

Re: [Haskell-cafe] Decision procedure for foldr/foldl/foldl'?

2011-11-20 Thread Daniel Fischer
On Sunday 20 November 2011, 17:28:43, David Fox wrote: Does anyone have a quick way to decide which of the fold functions to use in a given situation? There are times when I would like to find out which to use in the quickest way possible, rather than reading a long explanation of why each

Re: [Haskell-cafe] Decision procedure for foldr/foldl/foldl'?

2011-11-20 Thread wren ng thornton
On 11/20/11 11:58 AM, Daniel Fischer wrote: On Sunday 20 November 2011, 17:28:43, David Fox wrote: Does anyone have a quick way to decide which of the fold functions to use in a given situation? There are times when I would like to find out which to use in the quickest way possible, rather