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. Help with getLine and getChar (Avery Robinson) 2. Re: Help with getLine and getChar (Daniel Fischer) 3. Re: Need some advices about university (Rustom Mody) 4. Re: Need some advices about university (Noah Diewald) 5. Re: Stack space overflow: using strict accumulator still fails (Daniel Fischer) ---------------------------------------------------------------------- Message: 1 Date: Thu, 27 Oct 2011 19:20:48 -0400 From: Avery Robinson <av...@averyrobinson.name> Subject: [Haskell-beginners] Help with getLine and getChar To: beginners@haskell.org Message-ID: <ca+6vedjkjq2+sjd_ewpanv-kuv+uzt7jrzd-09t4a04pzhb...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" I'm writing a program that calculates the maximum height of a stomp rocket (or any free falling object) given the starting height of the object and the amount of time that it takes to hit the ground. Here's what I have written: http://pastebin.com/KBJdPEJd The behavior that I am expecting is something like this: Starting height (ft): [user enters something here] Total air time (seconds): [user enters something here] Maximum height (ft): [the program's answer] Another? (Y/N) Then everything starts over if the user presses y, and execution stops if the user presses n. What actually happens: 1. The program waits for user input for both of the two fields before anything else, then it prints the prompts along with the answer. 2. The user needs to press enter before the their response to "Another? (Y/N)" is reacted to. I'd rather that the response is instant after just the y or n key is pressed. I don't really understand exactly how lazy evaluation works in the context of IO, so any help will be much appreciated. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20111027/9a469efa/attachment-0001.htm> ------------------------------ Message: 2 Date: Fri, 28 Oct 2011 01:45:20 +0200 From: Daniel Fischer <daniel.is.fisc...@googlemail.com> Subject: Re: [Haskell-beginners] Help with getLine and getChar To: beginners@haskell.org Cc: Avery Robinson <av...@averyrobinson.name> Message-ID: <201110280145.20270.daniel.is.fisc...@googlemail.com> Content-Type: Text/Plain; charset="utf-8" On Friday 28 October 2011, 01:20:48, Avery Robinson wrote: > I'm writing a program that calculates the maximum height of a stomp > rocket (or any free falling object) given the starting height of the > object and the amount of time that it takes to hit the ground. Here's > what I have written: http://pastebin.com/KBJdPEJd > > The behavior that I am expecting is something like this: > > Starting height (ft): [user enters something here] > Total air time (seconds): [user enters something here] > Maximum height (ft): [the program's answer] > Another? (Y/N) > > Then everything starts over if the user presses y, and execution stops > if the user presses n. > > What actually happens: > 1. The program waits for user input for both of the two fields before > anything else, then it prints the prompts along with the answer. > 2. The user needs to press enter before the their response to "Another? > (Y/N)" is reacted to. I'd rather that the response is instant after just > the y or n key is pressed. > > I don't really understand exactly how lazy evaluation works in the > context of IO, so any help will be much appreciated. That's not a problem with lazy evaluation and IO, it's a simple buffering issue. While in ghci stdin and stdout are normally unbuffered, for compiled programmes, they are usually line-buffered, so nothing will actually be printed to the terminal until a newline enters the output buffer or the output buffer is full. To get the prompts output before the user enters the inputs, you need to import System.IO and then you have the choice whether you want to a) turn off buffering completely (for the programme), that means performing hSetBuffering stdout NoBuffering at the beginning of main b) manually flush the output buffer for the prompts, that means do ... putStr "Starting height (ft): " hFlush stdout rawStartingHeight <- getLine ... etc. For small programmes like this, turning off buffering is simpler, but in programmes that produce a lot of output, it adds relevant overhead to output, so then manually flushing at the desired places is preferable. For the input, the situation is similar, you can globally turn off input buffering via 'hSetBuffering stdin NoBuffering' or do it locally in yOrN. However, the above may not work on Windows (buffering control used to be broken on Windows, I don't know the current state). ------------------------------ Message: 3 Date: Fri, 28 Oct 2011 08:01:38 +0530 From: Rustom Mody <rustompm...@gmail.com> Subject: Re: [Haskell-beginners] Need some advices about university To: beginners@haskell.org Message-ID: <caj+teofvwhzf2qbn273g0eolb84xmyf+1fffjet_hip7upi...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" On Fri, Oct 28, 2011 at 1:19 AM, Noah Diewald <n...@diewald.me> wrote: > It would be nice to know of a school somewhere in the US or Canada where > CS courses aren't taught mostly in Java. Is there such a place? > > I would love to find a school with strengths in FP and linguistics. > It seems you want to search for an intersection of linguistics + FP. There is nltk http://www.nltk.org/. Its in python -- hopefully better than java though not haskell. Note: I am not contending the significance of all the haskell-linguistics work -- just trying to broaden your search space for a university -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20111028/f74bf2a1/attachment-0001.htm> ------------------------------ Message: 4 Date: Fri, 28 Oct 2011 00:45:10 -0500 From: Noah Diewald <n...@diewald.me> Subject: Re: [Haskell-beginners] Need some advices about university To: beginners@haskell.org Message-ID: <4eaa4166.4010...@diewald.me> Content-Type: text/plain; charset="utf-8" On 10/27/2011 09:31 PM, Rustom Mody wrote: > On Fri, Oct 28, 2011 at 1:19 AM, Noah Diewald <n...@diewald.me > <mailto:n...@diewald.me>> wrote: > > It would be nice to know of a school somewhere in the US or Canada where > CS courses aren't taught mostly in Java. Is there such a place? > > I would love to find a school with strengths in FP and linguistics. > > > It seems you want to search for an intersection of linguistics + FP. > There is nltk http://www.nltk.org/. Its in python -- hopefully better > than java though not haskell. Thanks. I appreciate the help. I was aware of nltk. I know about GF, too. I guess functional programming is the important bit for me. It bothers me that all schools seem to be Java schools in the US but I guess I do actually want something more specific than anything but Java. Java is just the bad guy since it seems to be the only option so often. I kind of regret going on about it so much in my last email. It is better to focus on the positives. I like linguistics and I like functional programming. Something like this is right up my alley: Computational Semantics with Functional Programming by Jan van Eijck and Christina Unger. http://homepages.cwi.nl/~jve/cs/ I really like the idea of eventually being able to model natural language grammars using Haskell but for theoretical and descriptive work not just to process it. I hear that there are HPSG researchers in the US using systems written in Lisp, which sounds cool but is pretty rare and hard to find. I guess my dream school would have a good theoretical linguistics department and a good CS department with a big functional programming focus. I still need to learn a lot about CS, not just particular techniques that relate to language. Where I am applying now has a great linguistics department and a great CS department but I know that the courses I take in CS will be Java courses. It isn't really what I want but I've accepted that I'll just have to learn what I can on my own, which isn't so bad but having teachers and fellow students with similar interests around would be a lot nicer. And, I thank you for your help but I really am mostly curious about US universities with lots of FP goodies more than any particular software. My question is the same as the person who started this thread's. Where do you go in the US if you love functional programming and particularly Haskell? I would love some advice about universities. Google really doesn't know everything. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 490 bytes Desc: OpenPGP digital signature URL: <http://www.haskell.org/pipermail/beginners/attachments/20111028/0684c2c4/attachment-0001.pgp> ------------------------------ Message: 5 Date: Fri, 28 Oct 2011 10:43:56 +0200 From: Daniel Fischer <daniel.is.fisc...@googlemail.com> Subject: Re: [Haskell-beginners] Stack space overflow: using strict accumulator still fails To: beginners@haskell.org Message-ID: <201110281043.56155.daniel.is.fisc...@googlemail.com> Content-Type: Text/Plain; charset="iso-8859-1" On Thursday 27 October 2011, 17:02:46, Hugo Ferreira wrote: > But something seems to be wrong here. If I do: > > scoreRule_ r zs = Z.foldlz' (scoreElem r) (0, 0) zs > where scoreElem r s z = > let (nCorrect, nIncorrect) = s in > case ruleApplication r z of > Just tag -> if tag == correct > then (nCorrect+1, nIncorrect) > else (nCorrect, nIncorrect+1) > Nothing -> (nCorrect, nIncorrect) > where c = Z.cursor z > (correct,_) = c > > it works correctly, however this does not work: > > scoreRule_ r zs = Z.foldlz' (scoreElem r) (0, 0) zs > where scoreElem r (!nCorrect, !nIncorrect) z = > case ruleApplication r z of > Just tag -> if tag == correct > then (nCorrect+1, nIncorrect) > else (nCorrect, nIncorrect+1) > Nothing -> (nCorrect, nIncorrect) > where c = Z.cursor z > (correct,_) = c > > I have been staring at this for some time now, but cannot > understand why it does not work. Any ideas? No. Looks perfectly okay (well, the indentation is wrong, but that's the same for the working version above and is probably due to the mail client). Can you post the complete source for diagnosis? ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 40, Issue 44 *****************************************