I have a list (rs) of lists of length 4 with integers from 0..7, I would like a function to return a list of length 8 that has at each index the number of times said integers appear...
This seems awfully simple but I can't do shit... All I can think of is concatenating the list but then I don't know how to even proceed. I keep thinking of just iterating over arrays and adding state...
[i | i <- concat rs ]submitted by AceCream
[link] [6 comments]
I'm trying to implement a loop that prints an integer timer value from getPOSIXTime. This is my first attempt at composing monads and I'm fresh from completing LYAH (which didn't go into transformers, I have looked at a few resources on transformers but most of the examples are too complex for me to follow or weren't specific to IO + State).
I have about 40 lines of code here that I've managed to at least get the type checker to accept, but I'm not getting any output to the console:module Timer ( runTimer ) where import Control.Monad import Control.Monad.State import Data.Time.Clock.POSIX import Data.Int type ClockTime = Int64 posixToClockTime :: POSIXTime -> ClockTime posixToClockTime x = floor $ (read $ init $ show x) * 1000 curTime :: IO ClockTime curTime = posixToClockTime `fmap` getPOSIXTime newTime :: ClockTime -> State ClockTime Bool newTime newtime = state $ \oldtime -> if (oldtime < newtime) then (True, newtime) else (False, oldtime) runTimer :: StateT ClockTime IO () runTimer = forever $ do newtime <- lift curTime oldtime <- get let (b,_) = runState (newTime newtime) oldtime if (b == True) then lift $ putStrLn $ show newtime else do return ()
Ideally runTimer would loop and print the timestamp when it has changed, otherwise doing nothing.
I can call return runTimer from a GHCi prompt, but nothing is output and it returns immediately.
Basically, is there a way to get this to run or am I barking up the wrong tree?submitted by D_duck
[link] [8 comments]
Hi, i have a list like ["5","4"] and i would like to use the function read to get the value of each elements in my list
i know that i can doread "5" :: Int
but how can i apply that for an entire list?
I was thinking about using map likemap read ["5","4"] :: Int
ormap read ["5"::Int, "4":: Int]
but it does not work as far as i can tell.
Any help would be nice, sorry for the newbie question ^submitted by superancetre
[link] [4 comments]
(This is partly a genuine question, but there's also a bit of musing in amongst it)
I've known about the existence of the libraries mailing list for a while, and thought it might be something I'd sign up for at some point in the future.
The discussion around adding Foldable and Traversable to the Prelude - and the fact that it was a surprise to a lot of folks - got me thinking that I should probably sign up in order to keep up with these kind of changes / get a chance to have my say if I spot a problem with a proposal.
Does anyone on or familiar with the list know if it's the kind of list where casual, non-expert users are useful rather than background noise? Or am I conflating the libraries committee and the libraries mailing list?
On one hand, I wouldn't want to be a (potential) distraction.
On the other hand, I want to get in there to keep an eye on what is being proposed, mostly out of curiosity.
I also want to get in there for statistical reasons - I figure having more people active on the list might help with the mandate / marketing of the decisions the library committee makes.
Of course, that would fall to bits if the distribution of people for or against a proposal was correlated with the distribution of people too busy to sign up to another mailing list :)
Any info or thoughts would be appreciated.submitted by dalaing
[link] [2 comments]
Hi everyone, I would like to play with Buchi automata und would rather not start from scratch. Thanks.submitted by haskool
[link] [2 comments]
I'm trying to step through the ghc (Haskell Compiler) codebase, which is huge.
- What is the best way to step through a huge Haskell codebase ?
- What tools could help with this task ?
- Are there any tools like Visual Studio debugging ? (which I use when ramping up on huge C# projects)
- Is there a better way than to put 'trace' statements all over the code ?
It seems like 'trace' debugging and breaking things into tiny bits of functions is fine when I'm the one developing code bit by bit. But I find that model to be not that great when I want to understand some huge codebase and run the app, stop it at points and examine its behavior at runtime (like Visual Studio debugging).submitted by attilah
[link] [15 comments]
- September 1st, 2014: They tried to kill the Metal...I don't know where I'm going with that. But rock-n-roll with today's #haskell exercise http://lpaste.net/110331
- September 2nd, 2014: Good morning! Triangle Sums is our #haskell problem for today: http://lpaste.net/110404 No triangles were harmed in the solution of their sum (nor in the summation of their solution) http://lpaste.net/110432
- September 3rd, 2014: Pay It Forward. What? You didn't think I'd just say: today's #haskell problem is hard and leave it at that, did you? http://lpaste.net/110444 Paid. Or: a constructivist approach reduces the generated sets from 200M+ down to 8 possible solutions http://lpaste.net/110684 That's doable. ... and here is the 'Mr. Clean' version of the solution: fast, and neat. Groovy! http://lpaste.net/110685
- September 4th, 2014: Today's #haskell problem: Abacus words http://lpaste.net/110494 because MRFE says "I don't like your math problems; I want more word problems"
- September 5th, 2014: These 'edgy' relationships these days! Remember when today's #haskell problem didn't involve graph theory? http://lpaste.net/110543 Data.Graph FTW! http://lpaste.net/110571 A solution to today's 4sum #haskell problem, and it didn't require generating 1625702400 solutions!
- September 8th, 2014: We have puzzles 1 and 5 from the "Montley Stew" problem set for today's #haskell problem http://lpaste.net/110699 The solution-style to Montley Stew isswimming in list-compression stew http://lpaste.net/110750
- September 9th, 2014: King Tut! http://lpaste.net/110789 Our #haskell problem for today is NOT a Pyramid Scheme. Maybe.
- September 10th, 2014: 'Sed' is 'but(t)' just another word ... in "'laddin" http://lpaste.net/110833 Today's #haskell problem is mix-n-match words. "But(t) I sed ..." ARG! Enough with the 3rd-grade humor! On with the solution to the mix-n-match words! http://lpaste.net/110859
- September 11th, 2014: A-plus for you when you solve today's #haskell exercise http://lpaste.net/110862 But an F- (NOT an F# ... geddit?) for /usr/share/dict/words :/ A solution to today's injectInto #haskell problem http://lpaste.net/110891
- September 12th, 2014: Today's #Haskell problem comes from She. She who commands you solve it before coding it. http://lpaste.net/110925 So, you know: there it is. Okay, 'thurt' is a word in WHICH Universe? A solution to today's #haskell 'ditto' problem http://lpaste.net/110955
- September 15th, 2014: "The name of the game is Connect Four!" and today's #haskell problem http://lpaste.net/111065 as suggested by a tweet from @DrEugeniaCheng. I played Connect 4 against myself and lost! :/ A semi-solution to today's #haskell problem at http://lpaste.net/111105
- September 16th, 2014: There's more than one way to slice and dice a matrix for today's #haskell problem http://lpaste.net/111109 (follow-up to yesterday's Connect4) A Hack-n-slash solution to today's diagonal view of matrices. http://lpaste.net/111130 Thebonus solution is provided back at the Connect Four answer to make that game complete: http://lpaste.net/111105
- September 17th, 2014: Do you Yahoo!? Today's #haskell problem: connecting to Yahoo!'s financial webservice http://lpaste.net/111071 I like my java GREEN! http://lpaste.net/111238 (java means 'coffee') A solution to stock webservice #haskell problem.
- September 18th, 2014: Star (Tuna?) Fish? http://lpaste.net/111216 A radial word-finding/matching game is today's #haskell puzzle. Wait. Quantum...WHAT? http://lpaste.net/111259 A solution to today's #haskell problem using quantum superpositions to solve it. I'm not joking. STAR POWER! http://lpaste.net/edit/111259 A solution for pretty-printing the star-puzzle
- September 19th, 2014: Continued fractions and dual inversionals are today's #haskell problem http://lpaste.net/111067 It even comes with (thoughts about) flowers. #Ult Today's problem was inspired by a comment, then the main article, from @aperiodicalhttp://aperiodical.com/2013/11/from-the-mailbag-dual-inversal-numbers/#comment-611141 That was some LOOOOOOOONG Division! http://lpaste.net/111314 A solution to today's #haskell problem.
- September 22nd, 2014: Oh, noes! The 'M'-word! http://lpaste.net/111419 for today's #haskell exercise. Project Euler, problem 11: 'M' is for 'Monoid' http://lpaste.net/111435 A solution to today's #haskell problem.
- September 23rd, 2014: "Oh, the snark bites, with his teeth, dear." MACD Knife ... geddit? http://lpaste.net/111468 Today's #haskell problem is a technical indicator.
- September 24th, 2014: Jones, Smith, and Brown work at the Bank... but not Mr. Banks.A logic puzzle from 1957 for today's #haskell puzzle http://lpaste.net/111461. A pair of PhDs (http://lpaste.net/111580) helped to solve today's #haskell problem. Neatly, too, I might add.
- September 25th, 2014: Corned-beef hashi? http://lpaste.net/111452 No, that's not right, and now I'm hungry! :( Shoot! Well, anyway: today's #haskell problem.
- September 26th, 2014: HA! I TOLD you we'd be getting to cipher-text! http://lpaste.net/111459 From the 1700's, still: it IS cipher text for today's #haskell problem. Ooh! The Plot Thickens (like pea soup)! http://lpaste.net/111679 "ALLMENHAVING" and "be mis T r U st ed " is a solution to today's problem.
- September 29th, 2014: Big (Crypto) Generator! http://lpaste.net/111795 Today's #haskell problem is a follow-on to Friday's. Human Error ... WHAT human error?http://lpaste.net/111829 A solution to today's make-your-own-cypto-table #haskell problem
- September 30th, 2014: "I wanna be a blue-collar man!" Yes, but who, and which occupation? http://lpaste.net/111755 Today's #haskell problem addresses this. Plumber, ... or painter? IDK! http://lpaste.net/111876 TWO-solutions to today's #haskell problem (one of them MAY be correct... :/ )