[Haskell-cafe] Writing functions in Haskell.

Daniel Carrera dcarrera at digitaldistribution.com
Thu Apr 28 22:25:52 EDT 2005


Alright, I have what I believe must be a simple question. As one of the 
exercises for the Haskell tutorial I got I have to implement an 
alternative to the 'map' function.

This is what I have:

-----------------------------
my/prompt $ cat Test.hs
module Test
     where

my_map p [] = []
my_map p (x:xs) = p x : my_map p xs
my/prompt $ hugs

[snip]

Hugs.Base> :l Test
Test> :also Char
Char> map toUpper "Hello"
"HELLO"
Char> my_map toUpper "Hello"
ERROR - Undefined variable "my_map"
-----------------------------

I can define other functions now (e.g. Fibonacci, length of a list). So 
I'm not sure why I'm doing wrong here. Even if my syntax is wrong in 
some way, the function should be defined.

I would be grateful if anyone could point out my error.

Cheers,
Daniel.


More information about the Haskell-Cafe mailing list