Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. How is takeWhile implemented? (Carlos J. G. Duarte) 2. Re: How is takeWhile implemented? (illusionoflife) 3. Re: How is takeWhile implemented? (Carlos J. G. Duarte) 4. Re: How is takeWhile implemented? (KC) ---------------------------------------------------------------------- Message: 1 Date: Mon, 09 Jul 2012 18:01:49 +0100 From: "Carlos J. G. Duarte" <carlos.j.g.dua...@gmail.com> Subject: [Haskell-beginners] How is takeWhile implemented? To: beginners@haskell.org Message-ID: <4ffb0e7d.9090...@gmail.com> Content-Type: text/plain; charset="us-ascii" An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20120709/c11d1019/attachment-0001.htm> ------------------------------ Message: 2 Date: Mon, 09 Jul 2012 21:18:54 +0400 From: illusionoflife <ghostlymail...@gmail.com> Subject: Re: [Haskell-beginners] How is takeWhile implemented? To: beginners@haskell.org Message-ID: <1898327.KjfVtskrWR@miracle> Content-Type: text/plain; charset="us-ascii" On Monday, July 09, 2012 18:01:49 Carlos J. G. Duarte wrote: > underK k (x:xs) = (if x < k then [x] else []) ++ underK k xs > > -- from [2] ... how does this work anyway? > fibs = 0 : 1 : zipWith (+) fibs (tail fibs) > Which seems to work ok. How is takeWhile stopping at a given point and my > underK not? Look. In your implementation `underK' you *always* call itself. So, actually you implemented filter. takeWhile can be implemented(you can easily see source http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-List.html. Take notion that takeWhile do not call itself anymore if predicate is false. > Other question is regarding the "$" and ".". I know the $ has lower priority > and . has more, but is there any more difference that matters, I mean, can > I always use the "$" everywhere. For example, this main also works: main = > putStrLn $ show $ sum $ filter even $ takeWhile (<_M) fibs > Is it doing the same thing? It only affect amount of parensisis. Point is nice for high-order function magic. -- Best regards, illusionoflife. This mail is for mailing lists. For private, responce-warrantied mail use illusion.of.lif...@gmail.com. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: This is a digitally signed message part. URL: <http://www.haskell.org/pipermail/beginners/attachments/20120709/dea3ffd8/attachment-0001.pgp> ------------------------------ Message: 3 Date: Mon, 09 Jul 2012 21:30:40 +0100 From: "Carlos J. G. Duarte" <carlos.j.g.dua...@gmail.com> Subject: Re: [Haskell-beginners] How is takeWhile implemented? To: beginners@haskell.org Message-ID: <4ffb3f70.7070...@gmail.com> Content-Type: text/plain; charset="us-ascii" An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20120709/a0ec6461/attachment-0001.htm> ------------------------------ Message: 4 Date: Mon, 9 Jul 2012 14:26:44 -0700 From: KC <kc1...@gmail.com> Subject: Re: [Haskell-beginners] How is takeWhile implemented? To: "Carlos J. G. Duarte" <carlos.j.g.dua...@gmail.com>, beginners@haskell.org Message-ID: <CAMLKXy=PypLQ_AFRU1cFSU98ro1Yt0LAvanm=pzyq0yhl17...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" Then think of another approach to doing the problem. :) On Mon, Jul 9, 2012 at 1:30 PM, Carlos J. G. Duarte < carlos.j.g.dua...@gmail.com> wrote: > > Thanks, that's it. I had just to move the underK call inside the if: > > underK k (x:xs) = if x < k then x : underK k xs else [] > > ... I'm finding this to be a little too awkward to me! > > > -- -- Regards, KC -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20120709/e580581b/attachment-0001.htm> ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 49, Issue 10 *****************************************