On 2005/04/16, at 12:57, Hamilton Richards wrote:
At 10:50 AM +0900 2005/4/16, Kaoru Hosokawa wrote:
My solution based on Bernie's solution:
init :: [a] - [a]
init xs = foldr (left (length xs)) xs xs
left :: Int - a - [a] - [a]
left n x xs
| n == length xs = []
| otherwise = x : xs
At 6:53 PM +0200 2005/4/12, Henning Thielemann wrote:
On Tue, 12 Apr 2005, Hamilton Richards wrote:
Here's a solution:
init :: [a] - [a]
init xs = tail (foldr keep [] xs)
where
keep :: a - [a] - [a]
keep x [] = [x]
keep x [y] = [x,x]
keep x (y:z:zs) = x:x:y:zs
Nice idea!
I've been working through Thompson's exercises and got to one I could
not solve. It's Exercise 9.13. This is where I need to define init
using foldr.
init :: [a] - [a]
init Greggery Peccary ~ Greggary Peccar
This is as far as I got:
init xs = foldr left [] xs
On Sun, 2005-04-10 at 15:44 +0900, Kaoru Hosokawa wrote:
I've been working through Thompson's exercises and got to one I could
not solve. It's Exercise 9.13. This is where I need to define init
using foldr.
init :: [a] - [a]
init Greggery Peccary ~ Greggary Peccar
Hi,
Here's
Am Sonntag, 10. April 2005 08:44 schrieb Kaoru Hosokawa:
I've been working through Thompson's exercises and got to one I could
not solve. It's Exercise 9.13. This is where I need to define init
using foldr.
init :: [a] - [a]
init Greggery Peccary ~ Greggary Peccar
This is as
On second thoughts, I think Maybe [a] is nicer than (Bool, [a]).
D.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Kaoru Hosokawa [EMAIL PROTECTED] writes:
I've been working through Thompson's exercises and got to one I could
not solve. It's Exercise 9.13. This is where I need to define init
using foldr.
init :: [a] - [a]
init Greggery Peccary ~ Greggary Peccar
This is as far as I got:
Daniel Fischer [EMAIL PROTECTED] writes:
On second thoughts, I think Maybe [a] is nicer than (Bool, [a]).
Cool, this was my idea, too.
Best regards,
Christop Bauer
--
let () = let rec f a w i j = Printf.printf %.20f\r a; let a1 = a *. i /. j in
if w then f a1 false (i +. 2.0) j else f a1
On Mon, 11 Apr 2005, Christoph Bauer wrote:
Kaoru Hosokawa [EMAIL PROTECTED] writes:
I've been working through Thompson's exercises and got to one I could
not solve. It's Exercise 9.13. This is where I need to define init
using foldr.
init :: [a] - [a]
init Greggery Peccary ~
Am Montag, 11. April 2005 15:59 schrieb Christoph Bauer:
Ok, my second haskell program ;-):
module Init where
import Maybe
left :: a - Maybe [a] - Maybe [a]
left x None = (Just [])
Nothing, as below :-)
left x (Just l) = (Just (x:l))
init :: [a] - [a]
init xs =
10 matches
Mail list logo