Thanks
--
Posted via Talkway - http://www.talkway.com
Exchange ideas on practically anything (tm).
> I'm having a hard time understanding this functional programming
> thing. could someone please tell me the basic functioning of LISP?
> How it works in a sense?
it's all magic.
you ask a genie to do something and the genie asks the genies in its
hat, and so on. eventually they give you an answer, all the while
having fun in their little spaces. it's like the max on mtv (is that
still on?), but deeper.
you'd be surprised what a genie keeps in its hat!
thi
> I'm having a hard time understanding this functional programming
> thing. could someone please tell me the basic functioning of LISP?
I could tell you. But then I'd have to kill you.
Christopher
it is really very simple. functional programming means that it is
functional, like a machine, a family, a sex life. other programming is
by inference dysfunctional. so it isn't "how" it works, but "that" it
works that makes it "functional".
#:Erik
Well, I am fairly new here as well, and "basics of LISP" is quite
a huge question, but I can (attempt to) give you some food for thought
about this functional programming thing.
In functional programming, you treat functions as "first class values",
which means that you can treat them as any other value, i.e. create
them, and pass them around as you do with your integers and strings.
For a quick example, fire up your Lisp environment and type:
(defun create-adder (amount) (lambda (x) (+ x amount)))
This defines a function. When you call this function, e.g. with
(create-adder 3)
you get back some garbage that is the printed representation of
a function -- you get another of these thingies by typing
(symbol-function 'create-adder)
btw.
Now when you type
(funcall (create-adder 3) 4)
you get 7. What happens is: The function "funcall" expects one of
these function thingies you saw as its first argument, which it then
executes with the rest of the input line as parameters (funcall is a
"higher-order function", because it takes functions as input arguments).
So, you saw a function that creates functions and a function that takes
functions as its input--and also a function that has no name at all
being passed between these two. With this kind of power at your
fingertips, all kinds of neat tricks are possible and deep magic will
ensue. If you are interested, pick up a good book about Lisp, learn
and come back with new questions.
Have fun, Rudi
There is a newsgroup, comp.lang.functional, which discusses functional
programming more extensively. There is an FAQ at:
<http://www.cs.nott.ac.uk/Department/Staff/gmh/faq.html>
Briefly, it describes functional programming as:
"... a style of programming that emphasizes the evaluation of expressions,
rather than execution of commands. The expressions in these language are
formed by using functions to combine basic values. A functional language is
a language that supports and encourages programming in a functional style."
Common Lisp supports, but does not require, a functional style.