My advice, in that regard, is to do what I did when I (and many others) started learning Lisp.
Find a routine that
almost does what you want (there are plenty out there) and play with it. Try things out, see what happens.
If you write (or at some time wrote) BASIC, then Lisp should be very familiar to you.
The first thing you'll want to do in your routine is define the function using
defunAhhhhhh... but how does it work?
What are it's options?
for starters, if you define your function like this
(defun c:function_name....
it can be run from the command-line by typeing
function_name followed by the Enter key.
If you define it thus
(defun function_name...
It is run in this fashion:
(function_name)And that is just the tip of the iceberg
If...
If... If I had a fish...
If statements, at their simplest, are setup like this
(if (some_comparison)
(if_comparison_is_true_do_this)
(if_comparison_is_NOT_true_do_this_instead)
)
Just a little more complex, they can be defined like this
(if (some_comparison)
(progn
(if_comparison_is_true_do_this_first)
(do_this_next)
(then_do_this)
)
(progn
(if_comparison_is_NOT_true_do_this_instead)
(do_this_next)
(then_do_this)
)
)
And don't get even me started on
COND!
VariablesVariables are defined using
setq.
(setq variable_name (something_to_set_it_to))
It's not necessary to define your variables first, as in some other languages. Variables can be created and declared all at one time at any time in the program.
CommentsComments, in Lisp, are anything following a semicolon (
;) on a single line of code. They do not continue to the next line of code, like in
C so the following code demonstrates the right and wrong way to use comments
(defun c:my_routine ()
; This is my routine. It will do wonderful things.
; Like curing cancer and whatnot
Okay, maybe not cancer... but the common cold at least.
)
The above would result in an error becase the third line "
Okay, maybe not cancer... but the common cold at least." is not preceded by a semicolon (
;) and 'Okay' isn't a valid command.
How's that for starters?