Use the loeb function: loeb :: Functor a => a (a x -> x) -> a x
loeb x = fmap (\a -> a (loeb x)) x
To implement a basic spreadsheet processor. The processor should accept input of the form: |##|A |B |C |D |
|01|(* B1 C1)|2 |3 |(* A1 2)|
The output from this example should be: |##|A |B |C |D |
|01|6 |2 |3 |12 |
Cells may contain number literals, references to other cells of the form <letter><number>, or function applications of the form (<function> *<args>).
>>60
Nice try, thanks for playing. Monads actually have nothing to do with laziness, and everything to do with passing around arguments you don't care about, especially in recursive code.
Name:
!MILKRIBS4k2009-07-01 16:23
I don't "get" what is up with this HASKELL meme! Why is it so good! Is it better than C! Why is it not on as many platforms as C if it's so good! Is this all just a /prog/ meme!
Name:
Anonymous2009-07-01 16:29
>>63
You have no idea what you're getting into. If you tried to understand Haskell, your head (do anuses have heads?) would explode.
>>66
What I am trying to say now is that you should learn to use the question mark.
And please don't compare Haskell to /b/.
Also, how the hell is /b/ like a secret club?
>>69 JEEPERS CREEPERS! I just read the wiki on FACTORIALS and I did not understand one thing it said!
Name:
Anonymous2009-07-01 17:00
>>69 f@(_:fs) = 0 : 1 : zipWith (+) f fs FACTORIALS!
4/10, I nearly didn't notice.
Name:
Anonymous2009-07-01 18:32
>>62 Nice try
So, 4/10? 5/10? Monads actually have nothing to do with laziness...
Ah, 10/10.
Name:
Anonymous2009-07-01 21:44
>>68 loeb :: Functor a => a (a x -> x) -> a x
loeb x = fmap (\a -> a (loeb x)) x
Name:
Anonymous2009-07-01 21:52
>>72
It's true. Monads are a constuction in category theory.
Name:
Anonymous2009-07-01 22:16
>>72
You have in fact not been trolled. Haskell's monads are completely orthogonal to laziness; in fact, Haskell has some strict monads.
Now if you wanted to implement monads in a language without closures, then you'd be fucked. It would be like trying to compile Ruby.
Name:
Anonymous2009-07-01 22:25
>>75 not been trolled
Lessee: XD
Stupid smiley? Check. Laziness and monads
Tying together completely unrelated things? Check. So then they were like...
Fake history? Check. >>8
Responding to a post from a zillion years ago? Check.
>>82 Could not deduce (Functor m) from the context (Monad m)
arising from a use of `fmap' at <interactive>:1:13-16
Possible fix:
add (Functor m) to the context of an expression type signature
In the first argument of `(.)', namely `fmap'
In the second argument of `(=<<)', namely `fmap . flip id'
In the first argument of `fix', namely `(fmap . flip id =<<)'
Name:
Anonymous2009-07-02 5:05
new challenge: write the loeb function in a language that isn't haskell, and use it to do something useful.
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy