Sujet : Re: Command Languages Versus Programming Languages
De : ram (at) *nospam* zedat.fu-berlin.de (Stefan Ram) (ram@zedat.fu-berlin.de (Stefan Ram))
Groupes : comp.unix.shell comp.unix.programmer comp.lang.miscDate : 02. Apr 2024, 08:56:48
Autres entêtes
Organisation : Stefan Ram
Message-ID : <LISP-20240402085115@ram.dialup.fu-berlin.de>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13
Johanne Fairchild <
jfairchild@tudado.org> wrote or quoted:
You don't seem to much of a Lisp writer. Lisp writers have no problem
reading that indentation.
Well, there is the expression "write-only code", which shows
that a good Lisp writer may not necessarily be a good reader.
This is an example of LISP code:
( SETQ DIFF
( LAMBDA( X )
( COND
( ( ATOMP X )
( COND
( ( = X 'X )
1 )
( T
0 )))
( T
( COND
( ( =( CAR X )'SUM )
( LIST 'SUM( DIFF( CADR X ))( DIFF( CADDR X )))))))))
. For someone who has not learned LISP, this is difficult to read,
/not/ because of the indentation, but because the words used have no
meaning for him. Without the indentation it would be harder to read.
It defines ("SETQ") the name "DIFF" to be a function ("LAMBDA")
of one argument ("X"). When called, the functions tests
("COND") whether X is an atom ("ATOMP X"). In this case,
if X is the letter "X" the result is one, otherwise it's zero.
If X is not a atom, but a sum, we will return the sum of the
DIFFs of the augend and the added. This calls the same function
as the one defined. Yes! In LISP a function may call itself!