Take the 2-minute tour ×

I have been experimenting with functional programming and I still dont understand the concept. Do you guys know any good books or tutorials or examples that discuss this concept? Or if you could show small snippets about its usage, that would be great.

share|improve this question
Functional programming and homoiconicity aren't all that related to each other. Most functional languages are not homoiconic, and there are homoiconic languages that are not particularly functional, like Common Lisp, for example. In fact, as far as I'm concerned, the only functional, homoiconic language that comes to mind is Clojure. –  Matthias Benkard May 6 '09 at 8:46
Scheme is both a functional and homoiconic language. –  Rainer Joswig May 6 '09 at 22:39

4 Answers 4

up vote 2 down vote accepted

I believe that Why Functional Programming Matters by John Hughes is one of the best.

share|improve this answer

Learn lisp or scheme. The language is the datastructure is the language. Lisp code and Lisp data structures have the same syntax rules.

If you learn tcl, you can work with a language that's procedural and the data structure syntax rules are the same as the programming language syntax rules.

It's not -- strictly speaking -- a functional programming issue. It's more an issue with a few languages where the syntax rules for data and the syntax rules for the language are the same.

share|improve this answer

REBOL is a homoiconic language. The block! datatype in REBOL is a set of square brackets within which are any valid REBOL tokens, similar to an S-expression in Lisp. For instance:

series: [1 2 3 4]
foreach item series [
    print item

Now, let's express that a little differently:

series: [1 2 3 4]
for-body: [print item] ; This is the body of our foreach
foreach item series for-body

Though it was declared as data, we treated the block for-body as code when we passed it to the foreach function. If we ask REBOL what the type of the first item in the block for-body is — type? first for-body — it will tell us word! and not function! (or native! or action! or any of the other REBOL function types). The reason is that as data, for-body is just an unevaluated chunk of REBOL words. When we pass it to foreach only then does it get evaluated as code.

Some have called REBOL "like Lisp but without the parentheses" and I personally prefer it to Lisp, but you may not. Still, it's a great language to start with when you want to learn about homoiconicity, a subject I find fascinating.

share|improve this answer

Your Answer


