[Haskell-cafe] Trouble with currying and uncurrying...

2011-04-25 Thread Angel de Vicente
Hi, I'm reading The Craft of Functional Programming and I found something I don't understand in page 185. It says: Suppose first that we want to write a curried version of a function g, which is itself uncurried and of type (a,b) - c. curry g This funtion expects its arguments as a pair,

Re: [Haskell-cafe] Trouble with currying and uncurrying...

2011-04-25 Thread Angel de Vicente
Hi, On 25/04/11 14:20, Ozgur Akgun wrote: On 25 April 2011 14:11, Angel de Vicente ang...@iac.es mailto:ang...@iac.es wrote: curry :: ((a,b) - c) - (a - b - c) is the same as: curry :: ((a,b) - c) - a - b - c thanks, it makes sense now. Somehow I thought that adding the parenthesis

Re: [Haskell-cafe] Trouble with currying and uncurrying...

2011-04-25 Thread Angel de Vicente
Hi, On 25/04/11 14:21, Stephen Tetley wrote: On 25 April 2011 14:11, Angel de Vicenteang...@iac.es wrote: curry :: ((a,b) - c) - (a - b - c) curry g x y = g (x,y) Is expressing curry this way more illuminating? curry :: ((a,b) - c) - (a - b - c) curry g = \x y - g (x,y) That is,

Re: [Haskell-cafe] Haskell on-line judge for Programming Challenges / Contests ?

2011-04-14 Thread Angel de Vicente
Hi On 14/04/11 10:29, Dmitri O.Kondratiev wrote: I am looking for a site providing on-line automatic judge for Programming Challenges that can be coded in Haskell. For example this site: http://www.programming-challenges.com provides lots of interesting programming provlems:

Re: [Haskell-cafe] Haskell on-line judge for Programming Challenges / Contests ?

2011-04-14 Thread Angel de Vicente
Hi, On 14/04/11 12:16, Dmitri O.Kondratiev wrote: Angel, thanks! This site looks good. Do you know if spoj.pl http://spoj.pl has a search utility for problems? It would be great if they have 3n+1 problem I wrote about in a separate thread here. yes they have a search utility. Searching for

[Haskell-cafe] Typeclasses question in Real World Haskell book

2010-07-26 Thread Angel de Vicente
Hi, I'm stuck at page 151 of Real World Haskell and hoping that perhaps some of you can give me a hand here... The code that is giving me trouble is below. data JValue = JString String | JNumber Double | JBool Bool | JNull | JObject [(String,

Re: [Haskell-cafe] Typeclasses question in Real World Haskell book

2010-07-26 Thread Angel de Vicente
Hi, thanks for the answer. This is my first attempt at Typeclasses, and I think there is something deep that I don't understand... On 26/07/10 15:03, Daniel Fischer wrote: class JSON a where toJValue :: a - JValue fromJValue :: JValue - Either JSONError a instance JSON JValue

Re: [Haskell-cafe] Typeclasses question in Real World Haskell book

2010-07-26 Thread Angel de Vicente
Hi, And now that we are at it... In the next page, 152 there is the following instance definition, but no explanation is (I think) given of what it means: instance (JSON a) = JSON [a] where until then all instance definitions where of the type instance JSON Int where ... How should I read

Re: [Haskell-cafe] Memoization in Haskell?

2010-07-09 Thread Angel de Vicente
Hi, thanks for all the replies. I'm off now to try all the suggestions... Cheers, Ángel de Vicente -- http://www.iac.es/galeria/angelv/ High Performance Computing Support PostDoc Instituto de Astrofísica de Canarias

[Haskell-cafe] Memoization in Haskell?

2010-07-08 Thread Angel de Vicente
Hi, I'm going through the first chapters of the Real World Haskell book, so I'm still a complete newbie, but today I was hoping I could solve the following function in Haskell, for large numbers (n 108) f(n) = max(n,f(n/2)+f(n/3)+f(n/4)) I've seen examples of memoization in Haskell to solve