What would be an example of an anaphoric conditional expression in Lisp?

What will be an example of anaphoric conditional expression in Lisp? Please also explain the code.

+6
conditional lisp
source share
2 answers

An example is Common Lisp LOOP :

 (loop for item in list when (general-predicate item) collect it) 

The variable IT has the meaning of a test expression. This is a function of the ANSI Common Lisp LOOP object.

Example:

 (loop for s in '("sin" "Sin" "SIN") when (find-symbol s) collect it) 

returns

  (SIN) 

because only "SIN" is the name for an existing character, here is the SIN character. In Common Lisp, by default, character names have internally capitalized names.

+4
source share

Paul Graham Lisp has the head of Anaphoric Macros .

In essence, this is a shorthand way of writing statements that avoids code repetition. For example, compare:

 (let ((result (big-long-calculation))) (if result (foo result))) 

and

 (if (big-long-calculation) (foo it)) 

where it is a special name that refers to everything that was calculated in (big-long-calculation) .

+9
source share

All Articles