Send Beginners mailing list submissions to beginners@haskell.org 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 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. Re: oddsFrom3 function (Kim-Ee Yeoh) 2. Re: oddsFrom3 function (akash g) 3. oddsFrom3 function (Debdut Karmakar) 4. Re: oddsFrom3 function (akash g) 5. Re: [Haskell-cafe] oddsFrom3 function (Daniel Trstenjak) ---------------------------------------------------------------------- Message: 1 Date: Mon, 17 Aug 2015 14:21:45 +0700 From: Kim-Ee Yeoh <k...@atamo.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] oddsFrom3 function Message-ID: <CAPY+ZdSESnROxj+keZ-UQ2d7ZKfs670ju8mi+OUqMegp=h8...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" On Mon, Aug 17, 2015 at 1:32 PM, Debdut Karmakar <debd...@gnulinuxed.tk> wrote: > Sorry, I wrote a wrong function, the correct version is: > > oddsFrom3 :: [Integer] > oddsFrom3 = 3 : map (+2) oddsFrom3 > You can get some idea of lambda evaluation here: http://chrisuehlinger.com/LambdaBubblePop/ (Alas it doesn't support let expressions much less let rec.) Once you have a modicum of intuition, you're now ready to appreciate the illustrated step-by-step evaluation of this infinite list: http://stackoverflow.com/a/19749422 Based on the SO answer, you can now work out your function on your own. -- Kim-Ee -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150817/12c3c48b/attachment-0001.html> ------------------------------ Message: 2 Date: Mon, 17 Aug 2015 14:12:11 +0530 From: akash g <akabe...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] oddsFrom3 function Message-ID: <CALiga_fgP9=MSeiB4dF01yFuf354mccqX0npY35+7ZLEut0=p...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Hi Rein, The initial version which the OP posted doesn't have a terminal value. The OP had posted the version that he'd wanted clarification on. On Mon, Aug 17, 2015 at 12:40 PM, Rein Henrichs <rein.henri...@gmail.com> wrote: > It will absolutely work. Lists can be infinite in Haskell and infinite > lists are productive: > > ?> take 5 oddsFrom3 > [3,5,7,9,11] > > > On Mon, Aug 17, 2015 at 12:05 AM Debdut Karmakar <debd...@gnulinuxed.tk> > wrote: > >> On 2015-08-17 02:35, akash g wrote: >> >> Not a problem. And I should have thought about what you wanted too. >> >> This version will give you an infinite list of odd numbers from 3. >> >> >> On Mon, Aug 17, 2015 at 12:02 PM, Debdut Karmakar <debd...@gnulinuxed.tk> >> wrote: >> >>> Sorry, I wrote a wrong function, the correct version is: >>> >>> oddsFrom3 :: [Integer] >>> oddsFrom3 = 3 : map (+2) oddsFrom3 >>> -- >>> >>> A* GNU <http://gnu.org> Linux <http://www.linuxfoundation.org/>* Patron >>> >>> _______________________________________________ >>> Beginners mailing list >>> Beginners@haskell.org >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >>> >>> >> _______________________________________________ >> Beginners mailing >> listBeginners@haskell.orghttp://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> >> I know that it will evaluate to a list of odd numbers >= 3, but how? >> >> Thanks, anyway. >> -- >> >> A* GNU <http://gnu.org> Linux <http://www.linuxfoundation.org/>* Patron >> _______________________________________________ >> Beginners mailing list >> Beginners@haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150817/10c45095/attachment-0001.html> ------------------------------ Message: 3 Date: Mon, 17 Aug 2015 04:44:55 -0400 From: Debdut Karmakar <debd...@gnulinuxed.tk> To: Haskell Beginner Mailing List <beginners@haskell.org>, Haskell Cafe Mailing List <haskell-c...@haskell.org> Subject: [Haskell-beginners] oddsFrom3 function Message-ID: <d319af34ed05674d9b421a0ed2b72...@gnulinuxed.tk> Content-Type: text/plain; charset="utf-8" I am a haskell beginner and wondering how the following function works (in procedure) : oddsFrom3 :: [Integer] oddsFrom3 = 3 : map (+2) oddsFrom3 Thanks for your help. -- A GNU [1] LINUX [2] Patron Links: ------ [1] http://gnu.org [2] http://www.linuxfoundation.org/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150817/6bba7136/attachment-0001.html> ------------------------------ Message: 4 Date: Mon, 17 Aug 2015 14:16:10 +0530 From: akash g <akabe...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] oddsFrom3 function Message-ID: <caliga_eposppcxvoz4bkpwh82f66jabhoa67ggkz1rcjsq6...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" You can also peruse SICP for knowing about how lazy evaluation works. The explanations are nice. It is in lisp, though. https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-24.html#%_sec_3.5 On Mon, Aug 17, 2015 at 2:12 PM, akash g <akabe...@gmail.com> wrote: > Hi Rein, > > The initial version which the OP posted doesn't have a terminal value. > The OP had posted the version that he'd wanted clarification on. > > On Mon, Aug 17, 2015 at 12:40 PM, Rein Henrichs <rein.henri...@gmail.com> > wrote: > >> It will absolutely work. Lists can be infinite in Haskell and infinite >> lists are productive: >> >> ?> take 5 oddsFrom3 >> [3,5,7,9,11] >> >> >> On Mon, Aug 17, 2015 at 12:05 AM Debdut Karmakar <debd...@gnulinuxed.tk> >> wrote: >> >>> On 2015-08-17 02:35, akash g wrote: >>> >>> Not a problem. And I should have thought about what you wanted too. >>> >>> This version will give you an infinite list of odd numbers from 3. >>> >>> >>> On Mon, Aug 17, 2015 at 12:02 PM, Debdut Karmakar <debd...@gnulinuxed.tk >>> > wrote: >>> >>>> Sorry, I wrote a wrong function, the correct version is: >>>> >>>> oddsFrom3 :: [Integer] >>>> oddsFrom3 = 3 : map (+2) oddsFrom3 >>>> -- >>>> >>>> A* GNU <http://gnu.org> Linux <http://www.linuxfoundation.org/>* Patron >>>> >>>> _______________________________________________ >>>> Beginners mailing list >>>> Beginners@haskell.org >>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >>>> >>>> >>> _______________________________________________ >>> Beginners mailing >>> listBeginners@haskell.orghttp://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >>> >>> I know that it will evaluate to a list of odd numbers >= 3, but how? >>> >>> Thanks, anyway. >>> -- >>> >>> A* GNU <http://gnu.org> Linux <http://www.linuxfoundation.org/>* Patron >>> _______________________________________________ >>> Beginners mailing list >>> Beginners@haskell.org >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >>> >> >> _______________________________________________ >> Beginners mailing list >> Beginners@haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150817/aa9f61ae/attachment-0001.html> ------------------------------ Message: 5 Date: Mon, 17 Aug 2015 10:49:50 +0200 From: Daniel Trstenjak <daniel.trsten...@gmail.com> To: haskell-c...@haskell.org, Haskell Beginner Mailing List <beginners@haskell.org> Subject: Re: [Haskell-beginners] [Haskell-cafe] oddsFrom3 function Message-ID: <20150817084950.GA18244@machine> Content-Type: text/plain; charset=us-ascii Hi Debdut, On Mon, Aug 17, 2015 at 04:44:55AM -0400, Debdut Karmakar wrote: > I am a haskell beginner and wondering how the following function works (in > procedure) : > > > oddsFrom3 :: [Integer] > oddsFrom3 = 3 : map (+2) oddsFrom3 > > > Thanks for your help. Try to expand a few steps of the recursion by hand e.g.: 3 : (map (+2) (3 : map (+2) (3 : map (+2) ...))) As you can see, the deeper you go more 'map (+2)' are applied to '3'. Greetings, Daniel ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 86, Issue 13 *****************************************