readFile reads the file lazily so it isn't closed until the entire contents
have been consumed.
Try System.IO.Strict.readFile, which will read the entire file at once.
zaxis writes:
> hitSSQ :: String -> [Int] -> IO ()
> hitSSQ no hitNum = do
>let newNum = unwords $ [no] ++ map (\n -> show
alts :: [a] -> [a]
alts xs = map fst . filter snd $ zip xs (cycle [False, True])
Prelude> alts [0, 1..5]
[1,3, 5]
On Sunday Jun 6, 2010, at 10:46 AM, R J wrote:
> What's the cleanest definition for a function f :: [a] -> [a] that takes a
> list and returns the same list, with alternate items re
BTW, "\n -> show n" is equivalent to "show" .
On Monday Jun 7, 2010, at 8:37 PM, zaxis wrote:
>> Yes, and i can use appendFile too.
>>
>> appendFile "ssqHitNum.txt" $ unwords $ [no] ++ map (\n -> show n) hitNum
>> ++ ["\n"]
>
___
Haskell-Cafe mailing
f :: [a] -> [a]
f = filter snd $ zip a (cycle [True, False])
On Monday, June 7, 2010, Ozgur Akgun wrote:
> or, since you don't need to give a name to the second element of the list:
>
> f :: [a] -> [a]
> f (x:_:xs) = x : f xsf x = x
>
>
>
>
> On 7 June 2010 20:11, Ozgur Akgun wrote:
>
> i think
you might have forgotten the "map fst $" part.
>
> Best,
>
>
> On 8 June 2010 14:51, Bill Atkins wrote:
>
> f :: [a] -> [a]
> f = filter snd $ zip a (cycle [True, False])
>
> On Monday, June 7, 2010, Ozgur Akgun wrote:
>> or, since you don't ne
Can you post an example of your code? mapM and map are actually for pretty
distinct purposes.
If you find yourself wanting to map over a pure list in monadic code, you
should really look at applicative style, e.g.:
import Control.Applicative
data Struct = deriving (Read)
readStruc
The answer is still applicative. :)
On Monday Jul 26, 2010, at 10:06 AM, Kevin Jardine wrote:
> On Jul 26, 3:49 pm, Kevin Jardine wrote:
>> I find
>> myself wishing that f (m [a]) just automatically returned m f([a])
>> without me needing to do anything but I expect that there are reasons
>> wh
Seconded.
On Monday Jul 26, 2010, at 6:24 PM, Edward Z. Yang wrote:
> IMO, if you really want a wildcard, just write a lambda...
>
>\x -> foo 1 x 3
>
> Cheers,
> Edward
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.hask
The let's aren't really statements, they're just named expressions and are
still subject to lazy evaluation.
In:
let x = putStrLn "Name" >> getLine
putStrLn "Welcome"
x
The program will print:
Welcome
Name?
and then prompt for input, even though the let comes first.
And if you never ran
Not sure if I understood what you're trying to do, but development will be
easier if you minimize your IO, e.g. :
maxLineLength :: Int
maxLineLength = 72
wrapLine :: String -> [String]
wrapLine "" = []
wrapLine line
| length line <= maxLineLength= [line]
| otherwise
row alight upon my shoulder for a moment, while I was h
> oeing in a village garden, and I felt that I was more distinguished by t
> hat circumstance that I should have been by any epaulet I could have wor
> n.
> -Thoreau
> ===
>
>
> --- On Fri, 8/13/10, B
On Saturday Aug 14, 2010, at 12:50 AM, Conal Elliott wrote:
> And the IO monad is what Jerzy asked about. I'm pointing out that the state
> monad does not capture concurrency, and the "EDSL model" does not capture
> FFI. (Really, it depends which "EDSL model". I haven't seen one that can
> c
Oof, that's what I get for making "just one little change" without testing.
You're right.
On Saturday Aug 14, 2010, at 9:17 AM, Felipe Lessa wrote:
> On Sat, Aug 14, 2010 at 9:59 AM, Bill Atkins wrote:
>> | otherwise= l
k lines between individual
> quotes. THe only thing in the input text that should change are the lines
> longer than 72 characters, and they should be reformatted to one or more
> lines less than or equal to 72 characters.
>
> Michael
>
> --- On Sat, 8/14/10, Felipe Lessa
No, not really. Linked lists are very easy to deal with recursively and
Strings automatically work with any already-defined list functions.
On Sun, Aug 15, 2010 at 11:17 AM, Brandon S Allbery KF8NH <
allb...@ece.cmu.edu> wrote:
> More to the point, there's nothing elegant about [Char] --- its so
On Sunday, August 15, 2010, Tillmann Rendel
wrote:
> Bulat Ziganshin wrote:
>
> But in a world passing interpretation of IO, print is supposed to be a
> pure Haskell function. So the value world2 can only depend on the values
> of print and world1, but not on the actions of some concurrent thread.
Have you looked at creating Template Haskell splices to generate this for you?
On Friday Aug 20, 2010, at 2:21 PM, Andrew Coppin wrote:
> All I'm actually using it to do is generate a set of fixed-size containers
> (each of which has a bazillion class instances). I've got a variable-sized
> con
I don't think Template Haskell will be essential for this - you will probably
need a parser (probably written with Parsec), an eval function, and a state
monad to represent imperative changes made by the language you're evaluating.
Template Haskell is more for the elimination of boilerplate cod
In order to run apps built with wxHaskell on OS X, you're supposed to wrap
the binary using a script called macosx-app (
http://www.haskell.org/haskellwiki/WxHaskell/MacOS_X).
Unfortunately, after running "cabal install wx" this file is not in
"~/.cabal" - it's also not in the wxHaskell source.
D
Almost - "liftM modificationTime" has type Status -> IO EpochTime. Like
other IO functions (getLine, putStrLn), it returns an IO action but accepts
a pure value (the modification time)
Also, I like this style:
import Control.Applicative ((<$>))
blah = do
times <- mapM (PF.modificationTime <$>
Yep, you and Ben are both correct. Mea culpa and sorry for the bad answer.
Just curious: why does getModificationTime take an IO FileStatus rather than
a FileStatus?
On Thu, May 6, 2010 at 7:00 AM, Neil Brown wrote:
> Bill Atkins wrote:
>
> Almost - "liftM modificationTime&qu
When I run "cabal update" on my Mac (Snow Leopard, Intel), I get:
% cabal update
Downloading the latest package list from hackage.haskell.org
cabal: Codec.Compression.Zlib: incompatible zlib version
Anyone else seeing this? Reinstalling the Haskell Platform hasn't helped.
Thanks!
__
22 matches
Mail list logo