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

2007-02-26 Thread Antonio Cangiano
On 2/26/07, Thomas Hartman [EMAIL PROTECTED] 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,

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

2007-02-26 Thread Thomas Hartman
I'd heard of quick check, but haven't got my head around it. This seems like a good place to start. I understand you have to build an invariant and then you can automate against it, eg reverse of reverse is your original string prop_RevRev xs = reverse (reverse xs) == xs where types = xs::[Int]

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

2007-02-26 Thread Steve Downey
in addition, a good example of how to apply quickcheck would be really awesome. without using the standard drop g On 2/26/07, Thomas Hartman [EMAIL PROTECTED] wrote: Here's my, probably very obvious, contribution. What I'd like feedback on is 1) code seem ok? (hope so!) 2) What do you think

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

2007-02-26 Thread Steve Downey
ok maybe i should have read ahead. but still, i can see how to apply hunit, but not quickcheck. but quickcheck seems more powerful. On 2/26/07, Steve Downey [EMAIL PROTECTED] wrote: in addition, a good example of how to apply quickcheck would be really awesome. without using the standard drop g

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

2007-02-25 Thread iliali16
Hi I am trying to implement the function drop in haskell the thing is that I I have been trying for some time and I came up with this code where I am trying to do recursion: drop :: Integer - [Integer] - [Integer] drop 0 (x:xs) = (x:xs) drop n (x:xs) |n lList (x:xs) = dropN (n-1) xs :

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

2007-02-25 Thread Chris Eidhof
Hey, you're almost there: drop :: Integer - [a] - [a] drop 0 xs = xs drop n (x:xs) = drop (n-1) xs Your version fails when trying to do drop 10 [1..10]. My version fails when trying to do drop 10 [1..9], so you might want to try to see if you can come up with a solution for that! Good

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

2007-02-25 Thread Yitzchak Gale
Hi Iliali, You wrote: Hi I am trying to implement the function drop in haskell Chris Eidhof wrote: you're almost there... In case this is homework, you may also want to look at: http://www.haskell.org/haskellwiki/Homework_help Regards, Yitz ___

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

2007-02-25 Thread Antonio Cangiano
On 2/25/07, iliali16 [EMAIL PROTECTED] wrote: Hi I am trying to implement the function drop in haskell the thing is that I I have been trying for some time and I came up with this code where I am trying to do recursion: drop :: Integer - [Integer] - [Integer] drop 0 (x:xs) = (x:xs) drop n

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

2007-02-25 Thread Thomas Hartman
Here's my, probably very obvious, contribution. What I'd like feedback on is 1) code seem ok? (hope so!) 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? ** [EMAIL