Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

/prog/ challenge [HASKELL]

Name: Anonymous 2008-05-09 13:15

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>).

Name: Anonymous 2008-05-11 13:01

>>29,30
As with any Haskell concept, understanding it is just a matter of getting past all the intellectual masturbation on the part of the tutorial writer.

Loeb permits a set of functions to depend on each other's results in whatever arrangement they need...excluding circular dependencies of course.  Each function is given a reference to the whole (unsolved) result set, and when the function tries to read an element of that set, Haskell will recursively solve that function, cache its value, and return it.  As a base case, at least one function must ignore its argument.

If you've done any Haskell you've probably exploited this behavior plenty of times.  Loeb is just a generalization of it.

(Disclaimer: This is just going by what I've read of it on /prog/.)

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List