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 =
On 10/23/06, Neil Mitchell <[EMAIL PROTECTED]> wrote:
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 Hu
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:
http://haskell.org/hoogle/?q=buffering
suggests:
hSetBuffering stdin NoBuffering
Thanks
Neil
___
Ha
Donald Bruce Stewart wrote:
briqueabraque:
Hi,
How can I read a single character from standard output? I would like
the user to press a single key and the reading function return
imediately after that key is pressed.
so you want a function of type:
IO Char
asking Hoogle (http://has
briqueabraque:
> Hi,
>
> How can I read a single character from standard output? I would like
> the user to press a single key and the reading function return
> imediately after that key is pressed.
so you want a function of type:
IO Char
asking Hoogle (http://haskell.org/hoogle) we ge
Udo Stenzel wrote:
jim burton 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 s = unwords.take 5.unfoldr (Just . splitAt l) $ s ++ repeat ' '
where l = (leng
Hi,
How can I read a single character from standard output? I would like
the user to press a single key and the reading function return
imediately after that key is pressed.
Thanks,
Maurício
___
Haskell-Cafe mailing list
Haskell-Cafe@haskel
On Tuesday 24 October 2006 00:58, Greg Fitzgerald wrote:
> > test = print . take 3 =<< parseFiles
>
> I haven't had time to double-check this code, but something like this ought
> to work (no 'unsafe' operations!):
> test = sequence . take 3 . map (print . parseFile) =<< getFileFPs
>
> Let me know
On Mon, 2006-10-23 at 20:18 -0200, Maurício wrote:
>Hi,
>
>This small program says "Segmentation fault":
>
> module Main (Main.main) where
> import Data.Char
> import System.Time
> import System.Console.Readline
> main :: IO ()
> main = do
> readKey
> return ()
>
>I don't
jim burton 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 s = unwords.take 5.unfoldr (Just . splitAt l) $ s ++ repeat ' '
where l = (length s + 4) `div` 5
Of course no Haskeller
Hi,
This small program says "Segmentation fault":
module Main (Main.main) where
import Data.Char
import System.Time
import System.Console.Readline
main :: IO ()
main = do
readKey
return ()
I don't understand anything about readline, so I probably should have
to call some function
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"
Cheers,
Misha
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailm
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 about unsafeInterlea
jim burton <[EMAIL PROTECTED]> writes:
> tweak to in_fives
>
> > in_fives l = unfoldr (splitAtMb 5)
> > (l ++ replicate (5 - length l `mod` 5) 'X')
Whoops! Yes. And a slapped wrist for me for writing a
constant three times. Serves me right for not writing
groups_of n l = u
tweak to in_fives
> in_fives l = unfoldr (splitAtMb 5)
>(l ++ replicate (5 - length l `mod` 5) 'X')
--
View this message in context:
http://www.nabble.com/split-string-into-n-parts-tf2496941.html#a6961912
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabb
Jón Fairbairn-2 wrote:
>
>
> At a quick glance I can't see which bit needs it. The only
> mention of five is where it asks to split the string into
> groups of five characters (not into five equal parts),
> padded with Xs.
>
Oh dear, you're right. Sorry, I read in a rush. Thanks for the solut
jim burton <[EMAIL PROTECTED]> writes:
> Paul Brown-4 wrote:
> >
> >> Cool idea! Can you post a link for the puzzles?
> >
> 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
On 10/23/06, jim burton <[EMAIL PROTECTED]> 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
I got this:fifths :: String -> Stringfifths xs = let len = (length xs + 4) `div` 5 padded = take (len * 5)
Mark T.B. Carroll-2 wrote:
>
>
> FWIW this unholy thing works for me,
>
> fifths :: String -> String
>
> fifths = splitIntoN 5
>
> [snip]
>
>
Thanks Mark.
--
View this message in context:
http://www.nabble.com/split-string-into-n-parts-tf2496941.html#a6961461
Sent from the Haskell - Has
jim burton <[EMAIL PROTECTED]> writes:
(snip)
> *Main> fifths "IDOLIKETOBEBESIDETHESEASIDE"
> "IDOLI KETOBE BESIDE THESEA SIDEXX"
> *Main> fifths "12345"
> "1 23 45"
(snip)
FWIW this unholy thing works for me,
fifths :: String -> String
fifths = splitIntoN 5
splitIntoN :: Int -> String -> Strin
Paul Brown-4 wrote:
>
>> Cool idea! Can you post a link for the puzzles?
>
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,
jim burton <[EMAIL PROTECTED]> writes:
> I want to split a string into 5 parts of equal length, with the last fifth
> padded if necessary
(snip)
> *Main> fifths "12345"
> "1 23 45"
What's the correct answer for fifths "123456"? I can't figure out how to
meet both your constraints. Is "12 34 56 XX
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 = fifths' "" 0 s
> where l = (length s) `div` 5
[... snip ...]
Any thoughts? Thanks! This isn't homework BTW,
On Mon, Oct 23, 2006 at 08:48:24PM +0200, Bas van Dijk wrote:
> So it seems that 'parseFiles' tries to open all the ~18.000 files and gets
> exhausted when opening the 14994 file.
>
> What I would like is 'take 3 =<< parseFiles' to read only the first 3 files.
>
> Is this possible, and if so, wh
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 = fifths' "" 0 s
> where l = (length s) `div` 5
> fifths' xs c [] = xs ++ (replicate (l-c)
Hello Haskellers,
I'm wondering how to get the following to work:
I need to parse about 18.000 files. I would like to have a
function 'parseFiles' that parses all these files and returns the result in a
list.
When I execute 'test' from the simplified code below I get the error:
*** Exception:
[EMAIL PROTECTED] wrote:
]
] One way is to use existentials:
]
> data Seq1 a = forall b. (Pre a b, Show b) => Cons1 a (Seq1 b) | Nil1
]
] which perhaps not entirely satisfactory because we have to specify all
] the needed classes in the definition of Seq1.
Yes, that seems pretty burdensom
Hello Taral,
Monday, October 23, 2006, 1:12:38 PM, you wrote:
>> They probably are. However you get the overhead of creating the array
>> (when you don't really need O(1) random access) and every thread
>> signals the same semaphore which may lead to some congestion which
>> could slow things dow
Hello Cale,
Monday, October 23, 2006, 7:19:14 AM, you wrote:
> Speaking of boilerplate and the scrapping thereof, Data.Generics could
> theoretically also be used to write a relatively generic rnf/deepSeq,
> but in my attempts, it seems to be much much slower than using a
> specific normal form c
29 matches
Mail list logo