From: MikkelFJ Date: 2002-12-12T06:01:29+09:00 Subject: Re: functional programming "style" "zesar" wrote in message news:3df78342$0$38812$91cee783@newsreader01.highway.telekom.at... > i discovered ruby some weeks ago and i have to say now that i'm through with > the book of the pragmatic programmers i quite like the language. > > so far i've been coding in c/c++, java and COBOL (that was really painful > :) )... i guess that's why my code keeps on looking very procedural although > i'm writing ruby. > > i'm very fascinated by the few examples of functional programming-style i've > seen so far but i don't quite get the picture on how to "think this way"... > i mean i DO understand what the examples do and mean but i wouldn't be able > to write them myself... I don't think you'll find a Ruby reference on functional programming, but if you can accept other languages I've got two online books - one for OCaml and one for Scheme. Most principles should work well with Ruby, except for pattern matching as discussed in the newsgroup recently. The following book implements a range of minor applications using various programming styles - object oriented, functional and procedural. It's available online - actually only online unless you read french. I've linked to a chapter comparing functional and iterative style without preferring one over the other. The book is generally interesting in its approach towards developing applications (in harmony with its title), rather than trying inventing problems to teach a specific style. http://caml.inria.fr/oreilly-book/html/book-ora037.html#toc45 There is also the functional Bible, the Wizard book - which I have barely skimmed - it supposedly very good and very hairy. http://mitpress.mit.edu/sicp/sicp.html It's available online: http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-4.html Most other material I have seen have a combination of trivial useless examples to give the basics, and then advances towards 8-Queen problems to really illustrate the benefits of functional style - 8-Queen happens to be a nice pattern to sample pixels in, but otherwise it is hardly a very interesting example for real life applications. Mikkel