~ Office Supplies ~~ Buy Posters ~~ A-Z Products ~~ Website Advertising


S-expression - Wikipedia

<<Up     Contents

S-expression

An S-expression is a convention for representing data or an expression in a computer program in a text form. S-expressions are used in the Lisp programming language and Lisp-derived languages such as Scheme. The details of the syntax and supported data types vary in the different languages, but the most common feature is the extensive use of prefix notation with explicit use of brackets.

S-expressions are used for both code and data in Lisp. S-expressions were originally intended only as machine representations of human-readable M-expressions, but Lisp programmers soon started using S-expressions as the default notation.

S-expressions can either be single objects such as numbers, Lisp atoms[?] including the special atoms nil and t, or cons pairs[?], written as (x . y). Longer lists are made up of nested cons pairs, for example (1 . (2 . (3 . nil))) which can also be written as the easier to read and write (1 2 3).

Program code can be written in S-expressions, using prefix notation. An extra piece of syntactic sugar for writing Lisp programs is that the common expression (quote x) can be written with the abbreviation 'x.

Example:

 (defun factorial (x)
    (cond 
       ((eq x 1)  1)
       (t         (* x (factorial (- x 1))))
    )
 )

See also: car, cdr, cons

External links

wikipedia.org dumped 2003-03-17 with terodump




 
 
35 ct Very pink red gemmy RHODOCHROSITE Gorgeous gemstone freeform Single gem piece Very nice PRETTY
 35 ct Very pink red my RHODOCHROSITE Gorgeous freeform Single piece Very nice PRETTY 
 
17 grams light green new jade Serpentine gem stone Tumble polished cab cabbing rough 89 carat Nice
 17 grams light green new jade Serpentine Tumble polished cab cabbing 89 carat Nice 
 
78 carats CHRYSOBERYL gems stones Facet uncut raw rough gemstones crystals lot 4 to 5 ct 15 grams gr
 78 carats CHRYSOBERYL uncut raw crystals lot 4 to 5 ct 15 grams gr 
 
11 carats pink Rhodonite gem Polished rectangle blocks Cabbing cab cabochon rough gemstone freeforms
 11 carats pink Rhodonite Polished rectangle blocks Cabbing cab cabochon freeforms 
 
10 gram pink KUNZITE crystal specimen gem stone Cab cabbing cabochon rough uncut gemstone 51 carat 4
 10 gram pink KUNZITE crystal specimen Cab cabbing cabochon uncut 51 carat 4