[Haskell-beginners] self recursive lambda

sarfraz dragoon.empire at yahoo.fr
Mon Apr 9 17:57:22 CEST 2012


Can't seem to be able to debug the following:

import System.IO

nHead :: Int -> String -> String
nHead n str = if (length str) < n
              then str
              else if n ==0
                   then str
                   else (\x n str -> if n == 0 
-- this lambda does not work
                                     then str
                                     else x (n - 1) (tail str))

main = interact (nHead 5)

I see where the problem is. But surely it is possible to make a 
recursive lambda. (I want to use a lambda, i know how to do otherwise)

Sarfraz K.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120409/88ed1b2b/attachment.pgp>

More information about the Beginners mailing list