Re: [Haskell-cafe] split string into n parts

2006-10-24 Thread Bulat Ziganshin
Hello jim, Monday, October 23, 2006, 11:29:07 PM, you wrote: I want to split a string into 5 parts of equal length, with the last fifth padded if necessary, but can't get it right - here's what I've got - fifths :: String - String fifths s = unwords [a1,a2,a3,a4,a5] where l = (length

Re[2]: [Haskell-cafe] Exception: Too many open files

2006-10-24 Thread Bulat Ziganshin
Hello Bas, Tuesday, October 24, 2006, 1:03:55 AM, you wrote: Great it works! I didn't know about unsafeInterleaveIO [1]. Why is it called 'unsafe'? And how does the laziness work? Is it because of the 'let r = ... in (s, r)'? read either http://haskell.org/haskellwiki/IO_inside or Simon's

Re: [Haskell-cafe] Guards with do notation?

2006-10-24 Thread Joachim Breitner
Hi, Am Dienstag, den 24.10.2006, 00:44 +0300 schrieb Misha Aizatulin: hello all, why is it not possible to use guards in do-expressions like do (a, b) | a == b - getPair return a and b are equal Probably because it is not well-defined for all Monad what a

Re: [Haskell-cafe] Guards with do notation?

2006-10-24 Thread David House
On 24/10/06, Joachim Breitner [EMAIL PROTECTED] wrote: Am Dienstag, den 24.10.2006, 00:44 +0300 schrieb Misha Aizatulin: hello all, why is it not possible to use guards in do-expressions like do (a, b) | a == b - getPair return a and b are equal Probably

[Haskell-cafe] Re: Guards with do notation?

2006-10-24 Thread Benjamin Franksen
Joachim Breitner wrote: Hi, Am Dienstag, den 24.10.2006, 00:44 +0300 schrieb Misha Aizatulin: hello all, why is it not possible to use guards in do-expressions like do (a, b) | a == b - getPair return a and b are equal Probably because it is not

Re: [Haskell-cafe] Exception: Too many open files

2006-10-24 Thread Henning Thielemann
I don't know why these unsafe* functions are suggested so easily. Their name is chosen for good reason. On Mon, 23 Oct 2006, Bas van Dijk wrote: -- module Main where import Text.ParserCombinators.Parsec data T

[Haskell-cafe] Re: split string into n parts

2006-10-24 Thread Jón Fairbairn
I wrote: jim burton [EMAIL PROTECTED] wrote: Thankyou! It's http://www.rubyquiz.com - They are mostly well suited to haskell, lot of mazes etc. I've done 5 or 6 with varying degrees of success but have learned a lot. This thing about strings in fifths is from #1, the solitaire cipher.

Re: [Haskell-cafe] Re: Guards with do notation?

2006-10-24 Thread Joachim Breitner
Hi, Am Dienstag, den 24.10.2006, 12:48 +0200 schrieb Benjamin Franksen: Am Dienstag, den 24.10.2006, 00:44 +0300 schrieb Misha Aizatulin: hello all, why is it not possible to use guards in do-expressions like do (a, b) | a == b - getPair return a and

[Haskell-cafe] Re: Exception: Too many open files

2006-10-24 Thread Benjamin Franksen
Bas van Dijk wrote: On Monday 23 October 2006 21:50, Tomasz Zielonka wrote: unsafeInterleaveMapIO f (x:xs) = unsafeInterleaveIO $ do y - f x ys - unsafeInterleaveMapIO f xs return (y : ys) unsafeInterleaveMapIO _ [] = return [] Great it works! I didn't know

[Haskell-cafe] Solitaire cipher

2006-10-24 Thread jim burton
I'm a beginner having a go at implementing the Solitaire cipher (http://www.rubyquiz.com/quiz1.html as mentioned in another post) and I'd be really grateful if you could help me improve the code to be neater use more functions from the Prelude etc, or errors (eg at the moment I can't work out

Re: [Haskell-cafe] Haskell beginner questions

2006-10-24 Thread jim burton
Cybertronic wrote: Hi all, I'm pretty much new to Haskell however I'm stuck on something which is that I'm trying to create a function called display where I type in a DVD name, e.g. dvd1, it returns d (String) and the multiplication of q (Int) and i (Double) Here's what I've done so

Re: [Haskell-cafe] Solitaire cipher

2006-10-24 Thread Chris Kuklewicz
There are several problems with the behavior: *Main encrypt X *Main decrypt $ encrypt TANZP X So fixing this case would be the first thing to do, followed by: *Main encrypt hello LBVJW X *Main decrypt $ encrypt hello HELLO YFRTQ X

Re: [Haskell-cafe] Re: split string into n parts

2006-10-24 Thread Stefan Holdermans
Gah! Brain AWOL. I'm surprised no-one picked me up on that. Why didn't I use: splitAtMb n [] = Nothing splitAtMb n l = Just $ splitAt n l Actually, I've some code lying around doing exactly this (but without the padding ;)), written with the coalgebra inlined: split n = unfoldr $ \xs -

Re: [Haskell-cafe] Solitaire cipher

2006-10-24 Thread jim burton
Chris Kuklewicz wrote: There are several problems with the behavior: *Main encrypt X *Main decrypt $ encrypt TANZP X So fixing this case would be the first thing to do, followed by: *Main encrypt hello LBVJW X *Main decrypt $ encrypt hello HELLO YFRTQ X

[Haskell-cafe] Re: Read a single Char

2006-10-24 Thread Hans van Thiel
Hello, I have a similar question. When I use getChar with Hugs the newline (caused by pressing 'Enter') seems to be carried over into the next call of main, where it is treated as a single input character. The workaround is getLine and head, but it would be nice to drop the newline right away.

Re: [Haskell-cafe] Re: Read a single Char

2006-10-24 Thread Neil Mitchell
Hi I have a similar question. When I use getChar with Hugs the newline (caused by pressing 'Enter') seems to be carried over into the next call of main, where it is treated as a single input character. The workaround is getLine and head, but it would be nice to drop the newline right away. I

Re: [Haskell-cafe] Exception: Too many open files

2006-10-24 Thread Bas van Dijk
On Tuesday 24 October 2006 13:03, Henning Thielemann wrote: Is it possible to turn it into parseFiles :: [IO T] ? Then you can easily do sequence (take 3 parseFiles) Thanks, I think I go for this sollution: parseFiles :: IO [IO a] parseFiles = liftM (map parseFile) getFileFPs test =

[Haskell-cafe] Re: Solitaire cipher

2006-10-24 Thread Jón Fairbairn
jim burton [EMAIL PROTECTED] writes: In addition to Chris's comments, here are some more: data Card = Clubs Int | Spades Int | Diamonds Int | Hearts Int | JokerA | JokerB They aren't really Ints; better to define something like data FaceValue = Ace | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 |

[Haskell-cafe] Re: Re: Guards with do notation?

2006-10-24 Thread Benjamin Franksen
Joachim Breitner wrote: Am Dienstag, den 24.10.2006, 12:48 +0200 schrieb Benjamin Franksen: Am Dienstag, den 24.10.2006, 00:44 +0300 schrieb Misha Aizatulin: hello all, why is it not possible to use guards in do-expressions like do (a, b) | a == b - getPair

Re: [Haskell-cafe] Solitaire cipher

2006-10-24 Thread jim burton
Jón Fairbairn-2 wrote: jim burton [EMAIL PROTECTED] writes: In addition to Chris's comments, here are some more: [snip] Thanks for your comments Jon. I thought about making Cards an instance of Enum but didn't realise how helpful it would be in various places. I will use the shorter

Re: [Haskell-cafe] Re: Read a single Char

2006-10-24 Thread Hans van Thiel
No, it happens with Hugs on Fedora Core 5 (the fc5 Hugs package), not WinHugs. Thanks, Hans On Tue, 2006-10-24 at 17:27 +0100, Neil Mitchell wrote: Hi I have a similar question. When I use getChar with Hugs the newline (caused by pressing 'Enter') seems to be carried over into the next

[Haskell-cafe] Re: Read a single char

2006-10-24 Thread Maurí­cio
Hi getChar doesn't return until I press Enter. I need something that returns immediately after I press any key. It's a problem with buffering: hSetBuffering stdin NoBuffering This usually doesn't work on Windows: GHC 6.4.2 and 6.6: requires enter Hugs (console)

Re: [Haskell-cafe] Re: Read a single Char

2006-10-24 Thread Neil Mitchell
No, it happens with Hugs on Fedora Core 5 (the fc5 Hugs package), not WinHugs. Woops, the previous post in a different thread was talking about WinHugs, and I forgot to context-switch :) Does GHCi give the different behaviour? If so, one of them is probably a bug. Thanks Neil Thanks,

Re: [Haskell-cafe] Re: Read a single char

2006-10-24 Thread Dimitri Timofeev
Hi!Sorry if it is a bit off-topic in this thread.How can I input EOF symbol in WinHugs? Ctrl-Z and Ctrl-D don't work for me,so I can't use getContents function. Maybe there is a piece of documentationthat I should read? Thanks!-- Dimitri ___ Haskell-Cafe

Re: [Haskell-cafe] Re: Read a single char

2006-10-24 Thread Neil Mitchell
H How can I input EOF symbol in WinHugs? No possible way. If you could type the NUL character that might possibly work, but even then 1) you can't, 2) it might not. Do you have a particular need for typing the end of getContents in WinHugs? If so, I can open a bug and might be able to fix it

Re: [Haskell-cafe] Re: Read a single Char

2006-10-24 Thread John Meacham
On Tue, Oct 24, 2006 at 06:14:14PM +0200, Hans van Thiel wrote: I have a similar question. When I use getChar with Hugs the newline (caused by pressing 'Enter') seems to be carried over into the next call of main, where it is treated as a single input character. The workaround is getLine and

Re: [Haskell-cafe] Re: Read a single char

2006-10-24 Thread Dimitri Timofeev
On 10/25/06, Neil Mitchell [EMAIL PROTECTED] wrote: How can I input EOF symbol in WinHugs?No possible way. If you could type the NUL character that mightpossibly work, but even then 1) you can't, 2) it might not.Do you have a particular need for typing the end of getContents in WinHugs? If so, I

Re: [Haskell-cafe] Re: Read a single char

2006-10-24 Thread John Meacham
On Wed, Oct 25, 2006 at 01:06:28AM +0400, Dimitri Timofeev wrote: Sorry if it is a bit off-topic in this thread. How can I input EOF symbol in WinHugs? Ctrl-Z and Ctrl-D don't work for me, so I can't use getContents function. Maybe there is a piece of documentation that I should read? does F6

Re: [Haskell-cafe] Re: Read a single char

2006-10-24 Thread Dimitri Timofeev
On 10/25/06, John Meacham [EMAIL PROTECTED] wrote: does F6 work? it used to back with DOS something or another.It works in console Hugs, as well as Ctrl-Z, but does not work in WinHugs.-- Dimitri ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Re: Read a single char

2006-10-24 Thread Neil Mitchell
Hi Surely I can get along without getContents in WinHugs: last time I thought about it I just wanted to show getContents function to my students (and using hGetContents on a file handle seems to be better example). Another function that could be useful when teaching IO is 'interact', and it

[Haskell-cafe] Re: Configurations proposal

2006-10-24 Thread Brian Smith
On 10/24/06, Duncan Coutts [EMAIL PROTECTED] wrote: On the other hand, in Gtk2Hs I know one case where we do this. We have aGraphics.UI.Gtk.Cairo api module that is only included if Gtk was builtagainst Cairo. In any case it could be faked by using cpp to just not export anything rather than not

[Haskell-cafe] Haskell custom search engine

2006-10-24 Thread Donald Bruce Stewart
Google now lets us create our own custom search engine pages, so I whipped one up for Haskell, http://www.google.com/coop/cse?cx=015832023690232952875%3Acunmubfghzq also, as a demo, embedded http://www.cse.unsw.edu.au/~dons/search.html Seems to do a reasonable job of targetting just