Printer-friendly versionPrinter-friendly version

One easy way to get started at programming is to examine some typical interactions with an interpreter for the Scheme dialect of Lisp. Imagine that you are sitting at a computer terminal. You type an expression, and the interpreter responds by displaying the result of its evaluating that expression.

One kind of primitive expression you might type is a number. (More precisely, the expression that you type consists of the numerals that represent the number in base 10.) If you present Lisp with a number

486

the interpreter will respond by printing[5]

486

Expressions representing numbers may be combined with an expression representing a primitive procedure (such as + or *) to form a compound expression that represents the application of the procedure to those numbers. For example:

(+ 137 349)
486
(- 1000 334)
666
(* 5 99)
495
(/ 10 5)
2
(+ 2.7 10)
12.7

Expressions such as these, formed by delimiting a list of expressions within parentheses in order to denote procedure application, are called combinations. The leftmost element in the list is called the operator, and the other elements are called operands. The value of a combination is obtained by applying the procedure specified by the operator to the arguments that are the values of the operands.

The convention of placing the operator to the left of the operands is known as prefix notation, and it may be somewhat confusing at first because it departs significantly from the customary mathematical convention. Prefix notation has several advantages, however. One of them is that it can accommodate procedures that may take an arbitrary number of arguments, as in the following examples:

(+ 21 35 12 7)
75

(* 25 4 12)
1200

No ambiguity can arise, because the operator is always the leftmost element and the entire combination is delimited by the parentheses.

A second advantage of prefix notation is that it extends in a straightforward way to allow combinations to be nested, that is, to have combinations whose elements are themselves combinations:

(+ (* 3 5) (- 10 6))
19

There is no limit (in principle) to the depth of such nesting and to the overall complexity of the expressions that the Lisp interpreter can evaluate. It is we humans who get confused by still relatively simple expressions such as

(+ (* 3 (+ (* 2 4) (+ 3 5))) (+ (- 10 7) 6))

which the interpreter would readily evaluate to be 57. We can help ourselves by writing such an expression in the form

(+ (* 3
      (+ (* 2 4)
         (+ 3 5)))
   (+ (- 10 7)
      6))

following a formatting convention known as pretty-printing, in which each long combination is written so that the operands are aligned vertically. The resulting indentations display clearly the structure of the expression.[6]

Even with complex expressions, the interpreter always operates in the same basic cycle: It reads an expression from the terminal, evaluates the expression, and prints the result. This mode of operation is often expressed by saying that the interpreter runs in a read-eval-print loop. Observe in particular that it is not necessary to explicitly instruct the interpreter to print the value of the expression.[7]

[5] Throughout this book, when we wish to emphasize the distinction between the input typed by the user and the response printed by the interpreter, we will show the latter in slanted characters. [back]
[6] Lisp systems typically provide features to aid the user in formatting expressions. Two especially useful features are one that automatically indents to the proper pretty-print position whenever a new line is started and one that highlights the matching left parenthesis whenever a right parenthesis is typed. [back]
[7] Lisp obeys the convention that every expression has a value. This convention, together with the old reputation of Lisp as an inefficient language, is the source of the quip by Alan Perlis (paraphrasing Oscar Wilde) that Lisp programmers know the value of everything but the cost of nothing. [back]

Comments

I thought this was SICP in clojure?

Scheme dialect of Lisp? Shouldn’t this read Clojure dialect of Lisp?

meditation

You should best meditation techniques during those times when you are really struggling with cancer how to meditate properly When really busy or not able to meditate on thisObviously it is good too meditate even if this is 5 minutes a day of closing your eyes

1.1.1 Expressions | SICP in Clojure

Aventureux,effrayant alliage au-del

1.1.1 Expressions | SICP in Clojure

Fort,juteuse chose à l’intérieur utiliser derrière obscurit

peerie partialise bedlamps warmer

louis vuitton uk online louis vuitton shop louis vuitton leopard print scarf join in louis vuitton uk bags louis vuitton outlet store location cheap louis vuitton outlet nike free run femme rose et noir baskets mode nike nike air match nike huarache light 2011 http://www.gimp4liferacing.com/ match basket pas cher new york nike free run 2 ou 3 nike tn pas cher avis burberry boots burberry house check tote burberry vest women boffclubtoday.com burberry uk website burberry vest men burberry novacheck michael kors purse outlet michael kors purses on sale michael kors purses for cheap Discover More michael kors bags outlet cheap michael kors bags michael kors outlet handbags christian louboutin outlet store redbottom shoes louboutin discount Homepage louboutin heels christian louboutin sales red bottom heels

Belanja Online Cari Voucher

Belanja Online Cari Voucher Diskon, deal dan Kupon di GrantonWorld, jangan sampai ketinggalan berbagai penawaran special yang ditawarkan, serta dapatkan juga produk-produk yang lainnya yang tidak kalah murahnya dengan situs belanja online lainnya. ayo Cari Voucher Diskon, deal dan Kupon di GrantonWorld

Revision of 1.1.1 Expressions from 1 July 2009 - 8:50pm | SICP

Mi codificador está tratando de persuadir convencer que me mude a la red a partir de PHP.
. Siempre me ha disgustado la idea debido a los gastos

My homepage - Cerrajer

Revision of 1.1.1 Expressions from 1 July 2009 - 8:50pm | SICP

Hola , No hay duda de que su sitio web podría ser teniendo navegador compatibilidad cuestiones .
Cada vez que miro tu bitácora en Safari, que se ve muy bien
pero cuando sin embargo cuando IE , tiene algunas cuestiones que se
superponen. simplemente usted un dar cabeza rápido arriba!
Además de eso , maravilloso blogs !

Feel free to surf to my webpage :: Cerrajer

Revision of 1.1.1 Expressions from 1 July 2009 - 8:50pm | SICP

Wonderful artículo ! Esto es el tipo de
información que debe ser compartido todo el internet .
Vergüenza del Google para no publicar
superior ! Come on over y buscar asesoramiento de sitio
web . Gracias =)

Also visit my blog - Cerrajer

Revision of 1.1.1. Expressions from 30 June 2009 - 1:10am |

Su como usted conoce pensamientos ! Usted parece saber
mucho sobre este , como usted escribió el libro e
libro en él o algo así. me siento que acaba podría algunas ciento a unidad Casa un poco ,
en lugar de eso, es magnífico blog. Un fantástico ver .
Yo ciertamente volveré.

Stop by my web page: Cerrajer

Revision of 1.1.1 Expressions from 1 July 2009 - 8:50pm | SICP

Hurra , ​​eso es lo que estaba buscando explorar para , qué cosas datos !
presente aquí en este blogs , gracias admin de este website
 .

Stop by my weblog; Cerrajer

Revision of 1.1.1 Expressions from 1 July 2009 - 8:50pm | SICP

Awesome blog! Is your theme custom made or did you download it from
somewhere? A design like yours with a few simple tweeks would really make my
blog shine. Please let me know where you got your theme. Thanks

my blog post :: e cig reviews uk 2013 (thoughts.com)

Revision of 1.1.1. Expressions from 30 June 2009 - 1:10am |

Please let me know if you’re looking for a article author for your site.
You have some really great articles and I think I
would be a good asset. If you ever want to take some
of the load off, I’d really like to write some material
for your blog in exchange for a link back to mine. Please shoot me an e-mail if interested.
 Regards!

Check out my web site: Cerrajer

1.1.1 Expressions | SICP in Clojure

Good way of describing, and pleasant post to obtain facts regarding my presentation topic, which i am going to present in university.

Review my web site - Cerrajer

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <pre> <hr> <ul> <ol> <li> <dl> <dt> <dd> <img>
  • Lines and paragraphs break automatically.
  • Adds typographic refinements.

More information about formatting options