Re: [Haskell-cafe] Computing lazy and strict list operations at the same time

2006-09-29 Thread Brandon Moore
Andrew Pimlott wrote: This is a follow-up to a thread from June-July[1]. The question was how to write the function initlast :: [a] - ([a], a) initlast xs = (init xs, last xs) so that it can be consumed in fixed space: main = print $ case initlast [0..10] of

Re: [Haskell-cafe] Computing lazy and strict list operations at the same time

2006-09-27 Thread Brandon Moore
Andrew Pimlott wrote: This is a follow-up to a thread from June-July[1]. The question was how to write the function initlast :: [a] - ([a], a) initlast xs = (init xs, last xs) so that it can be consumed in fixed space: main = print $ case initlast [0..10] of

Re: [Haskell-cafe] Computing lazy and strict list operations at the same time

2006-09-26 Thread Andrew Pimlott
This is a follow-up to a thread from June-July[1]. The question was how to write the function initlast :: [a] - ([a], a) initlast xs = (init xs, last xs) so that it can be consumed in fixed space: main = print $ case initlast [0..10] of (init, last) -

Re: [Haskell-cafe] Computing lazy and strict list operations at the same time

2006-07-14 Thread Andrew Pimlott
On Mon, Jun 19, 2006 at 05:50:13PM +0100, Duncan Coutts wrote: On Mon, 2006-06-19 at 17:03 +0100, Jon Fairbairn wrote: il [] = error foo il [x] = ([], x) il (x:xs) = cof x (il xs) where cof x ~(a,b) = (x:a, b) -- ! From a quick test, it looks like

[Haskell-cafe] Computing lazy and strict list operations at the same time

2006-06-19 Thread C Rodrigues
Here's a puzzle I haven't been able to solve. Is it possible to write the initlast function? There are functions init and last that take constant stack space and traverse the list at most once. You can think of traversing the list as deconstructing all the (:) [] constructors in list.

Re: [Haskell-cafe] Computing lazy and strict list operations at the same time

2006-06-19 Thread Robert Dockins
On Jun 19, 2006, at 11:24 AM, C Rodrigues wrote: Here's a puzzle I haven't been able to solve. Is it possible to write the initlast function? There are functions init and last that take constant stack space and traverse the list at most once. You can think of traversing the list as

Re: [Haskell-cafe] Computing lazy and strict list operations at the same time

2006-06-19 Thread Jon Fairbairn
On 2006-06-19 at 15:24- C Rodrigues wrote: Here's a puzzle I haven't been able to solve. Is it possible to write the initlast function? There are functions init and last that take constant stack space and traverse the list at most once. You can think of traversing the list as

Re: [Haskell-cafe] Computing lazy and strict list operations at the same time

2006-06-19 Thread Duncan Coutts
On Mon, 2006-06-19 at 15:24 +, C Rodrigues wrote: Here's a puzzle I haven't been able to solve. Is it possible to write the initlast function? There are functions init and last that take constant stack space and traverse the list at most once. You can think of traversing the list as

Re: [Haskell-cafe] Computing lazy and strict list operations at the same time

2006-06-19 Thread Joel Reymont
Where's the solution and what is the repmin problem? On Jun 19, 2006, at 5:21 PM, Jerzy Karczmarczuk wrote: Such tricks become your second nature, when you take the solution (lazy) of the repmin problem by Richard Bird, you put it under your pillow, and sleep for one week with your head close

Re: [Haskell-cafe] Computing lazy and strict list operations at the same time

2006-06-19 Thread Duncan Coutts
On Mon, 2006-06-19 at 17:03 +0100, Jon Fairbairn wrote: On 2006-06-19 at 15:24- C Rodrigues wrote: Here's a puzzle I haven't been able to solve. Is it possible to write the initlast function? There are functions init and last that take constant stack space and traverse the list

Re: [Haskell-cafe] Computing lazy and strict list operations at the same time

2006-06-19 Thread Robert Dockins
On Jun 19, 2006, at 12:50 PM, Duncan Coutts wrote: On Mon, 2006-06-19 at 17:03 +0100, Jon Fairbairn wrote: On 2006-06-19 at 15:24- C Rodrigues wrote: Here's a puzzle I haven't been able to solve. Is it possible to write the initlast function? There are functions init and last that

Re: [Haskell-cafe] Computing lazy and strict list operations at the same time

2006-06-19 Thread jerzy . karczmarczuk
Joel Reymont writes: Where's the solution and what is the repmin problem? On Jun 19, 2006, at 5:21 PM, Jerzy Karczmarczuk wrote: Such tricks become your second nature, when you take the solution (lazy) of the repmin problem by Richard Bird, you put it under your pillow, and sleep for one