Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  Bug in solution for problem 19 (Nicol?s Hertzulis)


----------------------------------------------------------------------

Message: 1
Date: Thu, 19 Nov 2015 05:57:37 -0300
From: Nicol?s Hertzulis <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Bug in solution for problem 19
Message-ID:
        <CAHyojoHy9Yp41L80Xz_zVhJ7eCFfrpfj5rdvTrg=agra1oq...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

The penultimate solution for problem 19 of Ninety-Nine Haskell Problems
<https://wiki.haskell.org/H-99:_Ninety-Nine_Haskell_Problems> is giving the
result for the opposite of the given N.
e.g. rotate "abcdefgh" (-3) gives the result for rotate "abcdefgh" 3

Here's the problem https://wiki.haskell.org/99_questions/11_to_20 and the
solution https://wiki.haskell.org/99_questions/Solutions/19

I think it could be solved like this:

rotate xs n
    | n <= 0 = (reverse . take (negate n) . reverse $ xs) ++ (reverse .
drop (negate n) . reverse $ xs)
    | n > 0 = (drop n xs) ++ (take n xs)

I know it's not great, just keeping the spirit of the original solution

Is this the right list for reporting this kind of bugs?

Nicol?s
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20151119/4c06b2be/attachment-0001.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 89, Issue 33
*****************************************

Reply via email to