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 to write replicateM with interspersed guards? (Sebastien Zany) 2. Re: How to write replicateM with interspersed guards? (Sebastien Zany) 3. Re: How to write replicateM with interspersedguards? ( anyzhen ) 4. Re: A post about Currying and Partial application (Petar Radosevic) 5. Re: How to write replicateM with interspersed guards? (Brent Yorgey) 6. LZMA for Haskell? (Paulo Pocinho) 7. Re: [aklug] Re: VPS (Christopher Howard) 8. merge two files in to one file (kolli kolli) 9. Re: merge two files in to one file (Erik de Castro Lopo) 10. Re: merge two files in to one file (kolli kolli) ---------------------------------------------------------------------- Message: 1 Date: Tue, 4 Oct 2011 05:27:59 -0700 From: Sebastien Zany <sebast...@chaoticresearch.com> Subject: [Haskell-beginners] How to write replicateM with interspersed guards? To: Haskell Beginners <beginners@haskell.org> Message-ID: <caa+2x_vg_1r47-ztka5ksibeijdtil+amrubjfawxkqvb3h...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" What would be the idiomatic way to write a function which expands to the following? f n m = do { x1 <- m; guard (f [x1]); x2 <- m; guard (f [x1, x2]); . . . xn <- m; guard (f [x1,x2,...,xn]); } What I'm trying to do is generate a list of lists of length n with some property (checked by f) efficiently. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20111004/21248ef1/attachment-0001.htm> ------------------------------ Message: 2 Date: Tue, 4 Oct 2011 05:29:23 -0700 From: Sebastien Zany <sebast...@chaoticresearch.com> Subject: Re: [Haskell-beginners] How to write replicateM with interspersed guards? To: Haskell Beginners <beginners@haskell.org> Message-ID: <caa+2x_vlgjzdlkdm7d05t_6ts08xvserw6uglyesez2ng+c...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" Just realized I used "f" twice, make the outer one something else. On Tue, Oct 4, 2011 at 5:27 AM, Sebastien Zany < sebast...@chaoticresearch.com> wrote: > What would be the idiomatic way to write a function which expands to the > following? > > f n m = do { > x1 <- m; > guard (f [x1]); > x2 <- m; > guard (f [x1, x2]); > . > . > . > xn <- m; > guard (f [x1,x2,...,xn]); > } > > What I'm trying to do is generate a list of lists of length n with some > property (checked by f) efficiently. > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20111004/ab34faa8/attachment-0001.htm> ------------------------------ Message: 3 Date: Tue, 4 Oct 2011 21:23:59 +0800 From: " anyzhen " <jiangzhe...@qq.com> Subject: Re: [Haskell-beginners] How to write replicateM with interspersedguards? To: " Sebastien Zany " <sebast...@chaoticresearch.com>, " Haskell Beginners " <beginners@haskell.org> Message-ID: <tencent_7ffb677b5df2a35678943...@qq.com> Content-Type: text/plain; charset="gbk" like this? let inits' xs = drop 1 $ inits xs in let getLists n m = inits' take n (repeat m) in f m n =map (\x-> guard $ f x) xs where xs =getLists n m ------------------ Original ------------------ From: "Sebastien Zany"; Date: 2011?10?4?(???) ??8:27 To: "Haskell Beginners"; Subject: [Haskell-beginners] How to write replicateM with interspersedguards? What would be the idiomatic way to write a function which expands to the following? f n m = do { x1 <- m; guard (f [x1]); x2 <- m; guard (f [x1, x2]); . . . xn <- m; guard (f [x1,x2,...,xn]); } What I'm trying to do is generate a list of lists of length n with some property (checked by f) efficiently. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20111004/e72583ad/attachment-0001.htm> ------------------------------ Message: 4 Date: Tue, 4 Oct 2011 17:33:49 +0200 From: Petar Radosevic <pe...@wunki.org> Subject: Re: [Haskell-beginners] A post about Currying and Partial application To: beginners@haskell.org Message-ID: <20111004153349.GA8137@wunki-mac-pro.local> Content-Type: text/plain; charset=utf-8 Small update. I rewrote the post, this time with a hopeful beter explanation of Currying. http://www.wunki.org/posts/2011-10-04-currying-and-partial-application.html -- Petar Rado?evi?, Programmer wunki.org | @wunki ------------------------------ Message: 5 Date: Tue, 4 Oct 2011 13:41:43 -0400 From: Brent Yorgey <byor...@seas.upenn.edu> Subject: Re: [Haskell-beginners] How to write replicateM with interspersed guards? To: beginners@haskell.org Message-ID: <20111004174143.ga10...@seas.upenn.edu> Content-Type: text/plain; charset=us-ascii On Tue, Oct 04, 2011 at 05:27:59AM -0700, Sebastien Zany wrote: > What would be the idiomatic way to write a function which expands to the > following? > > f n m = do { > x1 <- m; > guard (f [x1]); > x2 <- m; > guard (f [x1, x2]); > . > . > . > xn <- m; > guard (f [x1,x2,...,xn]); > } > > What I'm trying to do is generate a list of lists of length n with some > property (checked by f) efficiently. Hmm, this is tricky. I can't think of any nice idiomatic way to do it -- if I really wanted something like this I'd just write an explicitly recursive function to do it step by step. One might hope to be able to do it using something in the monad-loops package [1], but the dependence of the tests on the list of results so far is a bit odd and doesn't fit any of the patterns in that package. The dependence of the tests on the whole list of results so far is actually quite odd. It looks like you are going to be repeating a lot of work calling f successively on [x1], [x1,x2], [x1,x2,x3], ... not to mention that to construct these successive lists you are going to have to append each new result to the end, which is O(n), making the whole thing O(n^2). I don't know anything about your function f, but I wonder whether you might be able to express it in the form f = h . mappend . map g for suitable functions h and g. For example, if f = (>10) . sum, then we could use h = (>10) . getSum g = Sum If so, rather than keeping the list of results so far as you iterate, you can just keep the result of (mappend . map g). Then when you compute the next result you just apply g to it, combine it with the previous result using `mappend`, then apply h to get a Bool for the call to guard. Alternatively, if f is insensitive to the order of its input list, you could keep the list in reverse order so that successive results can be *pre*pended in O(1); but this still (seemingly) wastes a lot of work. -Brent [1] http://hackage.haskell.org/package/monad-loops > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners ------------------------------ Message: 6 Date: Tue, 4 Oct 2011 21:06:27 +0100 From: Paulo Pocinho <poci...@gmail.com> Subject: [Haskell-beginners] LZMA for Haskell? To: beginners@haskell.org Message-ID: <CAK4i1qRsX5Y9w2CATmdm6wcy8h42bNB=OV13=rf93nnroym...@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 Hello list. I'd like to use LZMA to create/extract archives and compare CRC from archived files. What do I need to use LZMA in Haskell? There is a page called "Library/Compression" in the wiki [1] but it is from 2005, using LZMA version 4.06. Besides being old, I can only find the LZMA SDK version 9.20 for download. The only related package I can find on hackage is lzma-enumerator [2]. Trying to install with cabal requires an old header named lzma.h that is no longer available. [1] http://www.haskell.org/haskellwiki/Library/Compression [2] http://hackage.haskell.org/package/lzma-enumerator ------------------------------ Message: 7 Date: Tue, 04 Oct 2011 12:10:24 -0800 From: Christopher Howard <christopher.how...@frigidcode.com> Subject: Re: [Haskell-beginners] [aklug] Re: VPS To: Haskell Beginners <beginners@haskell.org> Message-ID: <4e8b6830.7050...@frigidcode.com> Content-Type: text/plain; charset=UTF-8; format=flowed On 10/04/2011 08:36 AM, adam bultman wrote: > What, do I have to *give* you one or something? Because I can, y'know. > > Just so long as you don't spam :) > > On 10/03/2011 06:59 PM, Christopher Howard wrote: >> On 10/03/2011 02:28 PM, adam bultman wrote: >>> Choward, any chance you have a legitimate email somewhere else you could >>> relay through, authenticated-style? >>> >> Legitimate!? My server is legitimate!!! >> >> Assuming you mean a gmail account or such... no. >> >>> You'd accept mail on your dynamic IP, but any outgoing mail sent via >>> your server would be relayed through a third party, via your username >>> and password. It's pretty easy to set up in Postfix, anyway, even with >>> TLS to boot. >>> > heh, heh... thanks, but I actually like the VPS idea better, as I was thinking about getting a cheap one to play around with anyway. Even the cheapest one comes with a static IP, so I could just receive the mail there and forward it on to my personal server, or something like that. As a point of curiosity: with your suggestion, do you rewrite the sender field, or do you send and receive e-mails with different addresses? It seems like a few years ago I remember trying to use a server belonging to one domain to send mail from another domain, and some of the mail was bounced back because the receiving servers detected that the domain in the sender field did not match that of the sending server. @Bruce: Thanks also for the offer, but I think I'll try out a VPS solution. -- frigidcode.com theologia.indicium.us ------------------------------ Message: 8 Date: Tue, 4 Oct 2011 18:47:16 -0600 From: kolli kolli <nammukoll...@gmail.com> Subject: [Haskell-beginners] merge two files in to one file To: beginners@haskell.org Message-ID: <CAE7D9k4gVvJvmb09f-0zyS9R1hcLdkwExdBY2=cgymvjhc6...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" Hi, Can anyone tell me how to merge two files in to one file. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20111004/2f5bec39/attachment-0001.htm> ------------------------------ Message: 9 Date: Wed, 5 Oct 2011 11:51:08 +1100 From: Erik de Castro Lopo <mle...@mega-nerd.com> Subject: Re: [Haskell-beginners] merge two files in to one file To: beginners@haskell.org Message-ID: <20111005115108.674f66377852ddabcffa4...@mega-nerd.com> Content-Type: text/plain; charset=US-ASCII kolli kolli wrote: > Can anyone tell me how to merge two files in to one file. What do you mean by 'merge'? A couple of possible meanings include: - Concatenate the second file onto the end of the first. - Line by line merge; line of first file, followed by line of second and so on. - Byte by byte merge; byte from the first file, followed by a byte from the second and so on. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ ------------------------------ Message: 10 Date: Tue, 4 Oct 2011 18:53:28 -0600 From: kolli kolli <nammukoll...@gmail.com> Subject: Re: [Haskell-beginners] merge two files in to one file To: beginners@haskell.org Message-ID: <CAE7D9k44_XvWXe_phSR6uDrb6-LWcX-tLr2=yb7p6rtc57v...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" all the lines of first file followed by all the lines of second file On Tue, Oct 4, 2011 at 6:51 PM, Erik de Castro Lopo <mle...@mega-nerd.com>wrote: > kolli kolli wrote: > > > Can anyone tell me how to merge two files in to one file. > > What do you mean by 'merge'? A couple of possible meanings include: > > - Concatenate the second file onto the end of the first. > > - Line by line merge; line of first file, followed by line of > second and so on. > > - Byte by byte merge; byte from the first file, followed by a byte > from the second and so on. > > Erik > -- > ---------------------------------------------------------------------- > Erik de Castro Lopo > http://www.mega-nerd.com/ > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20111004/6c0edd68/attachment.htm> ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 40, Issue 4 ****************************************