[Haskell-cafe] Hi can u explain me how drop works in Haskell

Antonio Cangiano acangiano at gmail.com
Mon Feb 26 03:35:47 EST 2007


On 2/26/07, Thomas Hartman <tphyahoo at gmail.com> wrote:
>
> Here's my, probably very obvious, contribution.
>
> What I'd like feedback on is
>
> 1) code seem ok? (hope so!)


Hi Thomas,

tail [] raises an error, therefore your code will fail when n > length xs (
e.g. mydrop 3 [1,2] will raise an exception, where [] is the expected
result). Your function is also limited to list of Int only (mydrop :: Int ->
[Int] -> [Int]).

2) What do you think of the tests I did to verify that this
> behaves the way I want? Is there a better / more idiomatic way to do
> this?


You may be interested in the following projects:

QuickCheck: http://www.cs.chalmers.se/~rjmh/QuickCheck/
HUnit: http://sourceforge.net/projects/hunit


Regards,
Antonio
-- 
http://antoniocangiano.com
Zen and the Art of Ruby Programming
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070226/28b6dcb5/attachment.htm


More information about the Haskell-Cafe mailing list