Re: [Haskell-cafe] Hints for Euler Problem 11

2007-08-18 Thread Lennart Augustsson
I agree. Computation on the type level does not imply computation on the value level. On 8/18/07, Tim Chevalier [EMAIL PROTECTED] wrote: On 8/17/07, Kim-Ee Yeoh [EMAIL PROTECTED] wrote: Incidentally, GHC's type checker is Turing complete. You already have as much static evaluation as is

Re: [Haskell-cafe] Hints for Euler Problem 11

2007-08-17 Thread Ketil Malde
On Thu, 2007-08-16 at 12:50 -0700, Kim-Ee Yeoh wrote: Aaron Denney wrote: On 2007-08-15, Pekka Karjalainen [EMAIL PROTECTED] wrote: A little style issue here on the side, if I may. You don't need to use (++) to join multiline string literals. text = If you want to have multiline

Re: [Haskell-cafe] Hints for Euler Problem 11

2007-08-17 Thread Kim-Ee Yeoh
Lennart Augustsson wrote: On 8/16/07, Kim-Ee Yeoh [EMAIL PROTECTED] wrote: 'Course not. The (++) function like all Haskell functions is only a /promise/ to do its job. What does assembling at compile time mean here: s = I will not write infinite loops ++ s But if the strings are all

Re: [Haskell-cafe] Hints for Euler Problem 11

2007-08-17 Thread Lennart Augustsson
It's very hard to tell if it's worth it or not. Concatenating constant strings will turn the string into WHNF, which might enable some other transformation. By having lots of little transformations that on their own look worthless you can make big improvements. I'd like to see as much static

Re: [Haskell-cafe] Hints for Euler Problem 11

2007-08-17 Thread L.Guo
. (map p011_toGroups) $ p011_input -- L.Guo 2007-08-17 - From: Ronald Guida At: 2007-07-20 11:39:50 Subject: [Haskell-cafe] Hints for Euler Problem 11 To handle the diagonals, my plan is to try

Re: [Haskell-cafe] Hints for Euler Problem 11

2007-08-17 Thread Lennart Augustsson
On 8/17/07, Kim-Ee Yeoh [EMAIL PROTECTED] wrote: Lennart Augustsson wrote: And as a previous poster showed, ghc does concatenate strings. And Haskell (as in the current language definition) does not. I was talking about Haskell. Haskell says nothing about compile time or run time in

Re: [Haskell-cafe] Hints for Euler Problem 11

2007-08-17 Thread Tim Chevalier
On 8/17/07, Kim-Ee Yeoh [EMAIL PROTECTED] wrote: Incidentally, GHC's type checker is Turing complete. You already have as much static evaluation as is practically possible. You already knew that. I don't see how the first statement implies the second. Cheers, Tim -- Tim Chevalier *

Re: [Haskell-cafe] Hints for Euler Problem 11

2007-08-16 Thread Kim-Ee Yeoh
Aaron Denney wrote: On 2007-08-15, Pekka Karjalainen [EMAIL PROTECTED] wrote: A little style issue here on the side, if I may. You don't need to use (++) to join multiline string literals. text = If you want to have multiline string literals \ \in your source code, you can break

Re: [Haskell-cafe] Hints for Euler Problem 11

2007-08-16 Thread Lennart Augustsson
But if the strings are all constant it's perfectly feasible to concatenate them at compile time. On 8/16/07, Kim-Ee Yeoh [EMAIL PROTECTED] wrote: Aaron Denney wrote: On 2007-08-15, Pekka Karjalainen [EMAIL PROTECTED] wrote: A little style issue here on the side, if I may. You don't need

Re: [Haskell-cafe] Hints for Euler Problem 11

2007-07-20 Thread Jules Bean
I came up with this function to try to extract the main diagonal. getDiag :: [[a]] - [a] getDiag = map (head . head) . iterate (tail . map tail) The problem is, this function doesn't work unless I have an infinite grid. Could anyone provide me with some hints to lead me in the right

Re: [Haskell-cafe] Hints for Euler Problem 11

2007-07-20 Thread Krzysztof Kościuszkiewicz
On Thu, Jul 19, 2007 at 11:39:26PM -0400, Ronald Guida wrote: In Problem 11, a 20x20 grid of numbers is given, and the problem is to find the largest product of four numbers along a straight line in the grid. The line can be horizontal, vertical, or diagonal. I found it easier to work with

Re: [Haskell-cafe] Hints for Euler Problem 11

2007-07-20 Thread Jim Burton
Ronald Guida wrote: Hi, again. I started looking at the Euler problems [1]. I had no trouble with problems 1 through 10, but I'm stuck on problem 11. I am aware that the solutions are available ([2]), but I would rather not look just yet. [...] FWIW I used a 2D array and a

Re: [Haskell-cafe] Hints for Euler Problem 11

2007-07-20 Thread Jim Burton
Jim Burton wrote: Ronald Guida wrote: Hi, again. I started looking at the Euler problems [1]. I had no trouble with problems 1 through 10, but I'm stuck on problem 11. I am aware that the solutions are available ([2]), but I would rather not look just yet. [...] FWIW I

[Haskell-cafe] Hints for Euler Problem 11

2007-07-19 Thread Ronald Guida
Hi, again. I started looking at the Euler problems [1]. I had no trouble with problems 1 through 10, but I'm stuck on problem 11. I am aware that the solutions are available ([2]), but I would rather not look just yet. In Problem 11, a 20x20 grid of numbers is given, and the problem is to

Re: [Haskell-cafe] Hints for Euler Problem 11

2007-07-19 Thread Dan Weston
Here's my hint, FWIW. Pick a data structure that makes your life easier, i.e. where horz, vert, and diag lines are handled the same way. Instead of a 2D structure, use a 1D structure. Then, data Dir = Horz | Vert | LL | LR stride Horz = 1 stride Vert = rowLength stride LL = rowLength - 1