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 fold a map (Tim Baumgartner) 2. question about comprehension or array creation (cchang) 3. Re: How to fold a map (Lyndon Maydwell) 4. Re: question about comprehension or array creation (Daniel Fischer) 5. Cleaning up after the Close button is pressed (Colin Hume) 6. Re: question about comprehension or array creation (Tim Perry) 7. haskell for FPGAS (David Blubaugh) 8. Re: Cleaning up after the Close button is pressed (Stephen Tetley) ---------------------------------------------------------------------- Message: 1 Date: Sat, 15 Jan 2011 13:57:16 +0100 From: Tim Baumgartner <baumgartner....@googlemail.com> Subject: [Haskell-beginners] How to fold a map To: beginners@haskell.org Message-ID: <aanlktiky4ohowvhrtrok4ffrcyg_kcen6ocrurpll...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" For all those still having problems with their folds (like myself), the following might be enlightning: http://www.youtube.com/watch?v=3063VGrrAdg Tim -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20110115/421b270a/attachment-0001.htm> ------------------------------ Message: 2 Date: Sat, 15 Jan 2011 14:19:05 +0000 (UTC) From: cchang <djvsr...@gmail.com> Subject: [Haskell-beginners] question about comprehension or array creation To: beginners@haskell.org Message-ID: <loom.20110115t145734-...@post.gmane.org> Content-Type: text/plain; charset=us-ascii Hi, I tried to create an array like the following. "array (1,3) [(1,1), (2,2), (3,3)]" through code in .hs e = [1,2,3] array (1,3) [(i,v) | i<-[1..3], v<-e] but I got "array (1,3) [(1,3), (2,3), (3,3)]" why v is always 3 in this case? Can anyone shed some light on this? Thanks, ------------------------------ Message: 3 Date: Sat, 15 Jan 2011 22:37:44 +0800 From: Lyndon Maydwell <maydw...@gmail.com> Subject: Re: [Haskell-beginners] How to fold a map To: Tim Baumgartner <baumgartner....@googlemail.com> Cc: beginners@haskell.org Message-ID: <AANLkTi=ogzbcz6qa-ee3huw3rghzrbzsvcenhsxqx...@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 Oh you~ On Sat, Jan 15, 2011 at 8:57 PM, Tim Baumgartner <baumgartner....@googlemail.com> wrote: > For all those still having problems with their folds (like myself), the > following might be enlightning: > http://www.youtube.com/watch?v=3063VGrrAdg > > Tim > > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > ------------------------------ Message: 4 Date: Sat, 15 Jan 2011 15:45:16 +0100 From: Daniel Fischer <daniel.is.fisc...@googlemail.com> Subject: Re: [Haskell-beginners] question about comprehension or array creation To: beginners@haskell.org Cc: cchang <djvsr...@gmail.com> Message-ID: <201101151545.17159.daniel.is.fisc...@googlemail.com> Content-Type: text/plain; charset="iso-8859-1" On Saturday 15 January 2011 15:19:05, cchang wrote: > Hi, > > I tried to create an array like the following. > > "array (1,3) [(1,1), (2,2), (3,3)]" > > through code in .hs > e = [1,2,3] > array (1,3) [(i,v) | i<-[1..3], v<-e] > > but I got > "array (1,3) [(1,3), (2,3), (3,3)]" > > why v is always 3 in this case? Can anyone shed some light on this? > Because [(x,y) | x <- list1, y <- list2] gives you the cartesian product of the two lists [each element of the first paired with each of the second], thus [(i,v) | i <- [1 .. 3], v <- e] = [(1,1),(1,2),(1,3),(2,1),(2,2),(2,3),(3,1),(3,2),(3,3)] and (as a known deviation from the Haskell Report), GHC overwrites array elements with multiple definitions on creation (according to the report, it should throw an error, but checking for duplicates would be too inefficient). Thus, with the list above, in each slot the three values 1, 2 and 3 are written (in that order), the last is the one you see afterwards. What you want is one of array (1,3) $ zip [1 .. 3] e {-# LANGUAGE ParallelListComp #-} -- Note the two `|' array (1,3) [(i,v) | i <- [1 .. 3] | v <- e] or equivalent. ------------------------------ Message: 5 Date: Sat, 15 Jan 2011 11:16:11 -0800 From: Colin Hume <lightwin...@hotmail.com> Subject: [Haskell-beginners] Cleaning up after the Close button is pressed To: <beginners@haskell.org> Message-ID: <snt140-w5693c7a0d077d05aea3efea2...@phx.gbl> Content-Type: text/plain; charset="iso-8859-1" Hi everyone, I have to perform cleanup when my application terminates. GHC.ConsoleHandler handles cleanup from Ctrl-C and Ctrl-Break very nicely under Windows. Unfortunately, the RTS does not support delivery of the Close button event. The reason given in rts/win32/ConsoleHandler.c is that an improperly-written Haskell handler will prevent the user from being able to kill the application. I have a few questions about this. 1) Is there a different way of cleaning up on Windows after the Close button is pressed? 2) It seems strange that GHC intentionally prevents the application from cleaning up in order to guarantee that it will terminate as the user expects. Why is it not the application developer's responsibility to ensure that it can be killed? Thanks, Colin -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20110115/ba190660/attachment-0001.htm> ------------------------------ Message: 6 Date: Sat, 15 Jan 2011 21:52:04 -0800 (PST) From: Tim Perry <perry2...@yahoo.com> Subject: Re: [Haskell-beginners] question about comprehension or array creation To: cchang <djvsr...@gmail.com>, beginners@haskell.org Message-ID: <50058.51238...@web161407.mail.bf1.yahoo.com> Content-Type: text/plain; charset=us-ascii The docs say: [(i, e)] a list of associations of the form (index, value). Typically, this list will be expressed as a comprehension. An association '(i, x)' defines the value of the array at index i to be x. I think the important part is that the array is used as a lookup for the values to associate with the array. The lookup returns a ?random? one of the three values in the list of tuples that have 1 as the first index. In this case it happens to be 3. And so on. This may help: Prelude Array> let e = [1,2,3] Prelude Array> array (1,3) [(i,v) | i<-[1..3], v<-e] array (1,3) [(1,3),(2,3),(3,3)] Prelude Array> array (1,9) [(i,v) | i<-[1..3], v<-e] array (1,9) [(1,3),(2,3),(3,3),(4,*** Exception: (Array.!): undefined array element Prelude Array> It couldn't look up a value for 4 so it failed... Does that help? --Tim ----- Original Message ---- From: cchang <djvsr...@gmail.com> To: beginners@haskell.org Sent: Sat, January 15, 2011 6:19:05 AM Subject: [Haskell-beginners] question about comprehension or array creation Hi, I tried to create an array like the following. "array (1,3) [(1,1), (2,2), (3,3)]" through code in .hs e = [1,2,3] array (1,3) [(i,v) | i<-[1..3], v<-e] but I got "array (1,3) [(1,3), (2,3), (3,3)]" why v is always 3 in this case? Can anyone shed some light on this? Thanks, _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners ------------------------------ Message: 7 Date: Sat, 15 Jan 2011 22:44:22 -0800 (PST) From: David Blubaugh <davidblubaugh2...@yahoo.com> Subject: [Haskell-beginners] haskell for FPGAS To: beginners@haskell.org Message-ID: <73108.58798...@web113308.mail.gq1.yahoo.com> Content-Type: text/plain; charset="iso-8859-1" To All, ? ? Has anyone developed HASKELL FOR FPGA development ?? ? Thank You, ? Daid Blubaugh ? ? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20110115/538aee9d/attachment-0001.htm> ------------------------------ Message: 8 Date: Sun, 16 Jan 2011 08:10:38 +0000 From: Stephen Tetley <stephen.tet...@gmail.com> Subject: Re: [Haskell-beginners] Cleaning up after the Close button is pressed To: Colin Hume <lightwin...@hotmail.com> Cc: beginners@haskell.org Message-ID: <aanlktiklrv4p7wmqk3saunwibramd961bhemokp2g...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Hi Colin If no-one has answered your query off-list you might want to punt it to the GHC users list or Haskell-cafe. Questions about a specific technology generally seem to get answered quicker on Haskell-cafe than Beginners, if they are specifically about GHC they seem to get the best answers on the GHC list. The Beginners list seems the best place for "general" elementary Haskell questions (answers are usually more explanatory than they would be on Haskell-cafe), but not questions about specific libraries or GHC specifics as such questions can be missed by people with the specific knowledge. Best wishes Stephen ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 31, Issue 15 *****************************************