[Haskell-cafe] Problems with function recursion in Haskell

Jonn Mostovoy jm at memorici.de
Mon May 9 13:56:08 UTC 2016

> Anybody can me help?

Yes, somebody can you help, as long as

 1. You provide enough information on what exactly do you want to
achieve, instead of asking to fix some code;
 2. You specify the input you feed to `getLine`. Top-level arguments
are guarded, while `if head s=="Q"` is not.

If you don't, nobody can you help.

A structure of a good question —

Hello, list.
I want to achieve <a goal>, to do that I came up with <a high-level
solution overview>, which is implemented <a link to the solution
However I encounter <a problem with implementation <debug log with all
the relevant inputs / files> | a problem with high-level solution
<reference to the relevant part of implementation | mention the lack
of implementation>>.
Can you help me with that?

Please note that if your goal is to do a homework it is highly
unlikely that you will find any help in the list or on stackoverflow.
Learning \neq passing a course.
Kindest regards,

On Mon, May 9, 2016 at 4:30 PM, Henson <jfsihenson at gmail.com> wrote:
> 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
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list