Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Foldr - mnemonic (foldr.com)
17 points by eru on May 23, 2008 | hide | past | favorite | 15 comments


I guess a short explanation is in order. foldr/foldl are folding or reduction operations. Heard of MapReduce? Well, fold is the reduction part (foldl specifically). It takes a list, function, and an accumulator and returns a list and the final accumulator value as a result. Pretty much every functional language has one and foldr/foldl names come from S/ML and later from Haskell.

You can see an example here: http://www.cse.unsw.edu.au/~en1000/haskell/hof.html The difference between foldr and foldl is how the list is processed and in the final list (left to right or right to left) so depending on what your function is, order does matter. Also, foldr is not tail recursive so it can't be optimized nicely.

These sorts of constructs are coming back to forefront of computing since they offer us a very efficient way to do distributed computing. I use MR all the time these days to deal with large data sets.


That's weird.. I just had an SML class and we never learned it was call folding... It was just being recursive on a list.

Also, the way the website is made the list seems to be infinite (stream) which is impossible in SML only in Haskell.


Regarding tail-recursion and optimization: In Haskell I guess it is the other way round - foldr is the more 'natural' function when you consider lazy evaluation.


Fess up, you found this while searching for a domain for a prospective file-hosting site you're working on, huh eru? :)


Not that glamorous.

I actually use it for reminding me which one is foldr and which is foldl in Haskell. I always forget.

I can not remember how I found it originally, though. Perhaps via Lambda the Ultimate.


You may have guessed that there is also foldl.com


I might be hung over right now but I don't get it?


Functional humor.


fold right/fold left


Brilliant... and what a waste of such a nice domain name!


fondlr.com is still available...


Personally I always liked:

http://tabularasa.org/



Effing brilliant. I wish I had thought of this...


The script fascinated me so much that I missed completely the fact that the page does have a body, which explains the mistery. Awesome.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: