I was curious if anybody knows of a book that's comprised of a collection of well commented code from various languages. Sort of like a collection of short stories, but each 'story' is a snippet of code performing a particular task. Ideally the book would contain examples from various languages such as Java, C, C++, Python, Ruby....
Reason why I'm looking for this is I'd like to gain familiarity with other languages in case I ever encounter them. I try an take breaks from the computer an go for walks throughout the day and would love to be able to bring a book with me and I felt like this would be great since I can continue learning but it's something where I can hopefully finish looking over a section each walk or something. Also wouldn't hurt to see how procedures and best practices are carried out in various languages.
Here is an example with a good amount of entries http://rosettacode.org/wiki/Sorting_algorithms/Quicksort