FACTOID # 121: Houses in English-speaking countries have the most rooms.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
WHAT'S NEW
RELATED ARTICLES
People who viewed "S expression" also viewed:
RECENT ARTICLES
More Recent Articles »
 

FACTS & STATISTICS    Simple view

  1. Select countries to view: (hold down Control key and click to select several)

     

     

    Compare:

     

     

  1. Select fact or statistic: (* = graphable)

     

     

     

  2. (OPTIONAL) Compare to statistic: (both need to be graphable)

     

     

     

  3. View result as:

     

       
(OR) SEARCH ALL encyclopedia, stats & forums:   

Encyclopedia > S expression

An S-expression (S stands for symbolic) 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 and DSSSL, and as mark-up in communications protocols like IMAP and John McCarthy's CBCL. 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 (affectionately known as Cambridge Polish notation).


S-expressions are used for both code and data in Lisp (see McCarthy Recursive Functions of Symbolic Expressions at http://www-formal.stanford.edu/jmc/recursive/recursive.html ). 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 more intelligibly as (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 in Lisp:

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

Example in Scheme:

 (define (factorial x) (if (= x 1) 1 (* x (factorial (- x 1))))) 


See also: car, cdr, cons


  Results from FactBites:
 
Expressions (14699 words)
Each expression occurs in the declaration of some (class or interface) type that is being declared: in a field initializer, in a static initializer, in a constructor declaration, or in the code for a method.
Within an FP-strict expression, all intermediate values must be elements of the float value set or the double value set, implying that the results of all FP-strict expressions must be those predicted by IEEE 754 arithmetic on operands represented using single and double formats.
A parenthesized expression is a primary expression whose type is the type of the contained expression and whose value at run time is the value of the contained expression.
Twisted Documentation: Lisp in Python (1876 words)
An S expression may be a symbol, a number, or a series of S expressions in parentheses.
It is followed by an S expression with the function parameters, and an S expression which is the body of the funciton.
As long as the user inputs an S expression to evaluate, it is passed to eval and the result printed.
  More results at FactBites »


 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments
Please enter the 5-letter protection code

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms.