[Haskell-cafe] Problems with function recursion in Haskell

Henson jfsihenson at gmail.com
Mon May 9 13:30:44 UTC 2016


Hi,

I'm new in Haskell and I need help in recursion.
That function below is returning "*** Exception: Prelude.head: empty 
list" and
I need resolve that:
execNTimes 0 [] = return()
execNTimes n xs = if n<=0  || null xs
     then return()
     else do
         si <- getLine
         let s = words si
             l = read (s !! 1) :: Int
             r = read (s !! 2) :: Int
         if head s=="Q"
             then do
                 let z = slice l r xs
                     m = foldl lcm 1 z
                 print (m `mod` (toInteger 1000000007))
             else do
                 let s1 = update l r xs
                 execNTimes (n-1) s1
         execNTimes (n-1) xs

  Anybody can me help?

Thank you,
Josenildo Silva


More information about the Haskell-Cafe mailing list