1 / 5

CSC 160 Computer Programming for Non-Majors Syntax Rules

CSC 160 Computer Programming for Non-Majors Syntax Rules. Prof. Adam M. Wittenstein Wittenstein@adelphi.edu http://www.adelphi.edu/~wittensa/csc160/. Syntax Rules #1-2. 1. Any picture is a legal expression; its value is itself. 2. A legal expression is the following in the given order:

gbronson
Télécharger la présentation

CSC 160 Computer Programming for Non-Majors Syntax Rules

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSC 160Computer Programmingfor Non-MajorsSyntax Rules Prof. Adam M. Wittenstein Wittenstein@adelphi.edu http://www.adelphi.edu/~wittensa/csc160/

  2. Syntax Rules #1-2 1. Any picture is a legal expression; its value is itself. 2. A legal expression is the following in the given order: --a left-parenthesis --a function name --one or more legal expressions --a right-parenthesis Its value is the resulting picture (what you get by applying the named function to the values of the smaller expressions inside it).

  3. Syntax Rule #3 • Any identifier, if already defined, is a legal expression. *In an empty DrScheme file, ballis not a legal expression. *In a file containing (define ball ), ballis a legal expression.

  4. Syntax Rule #4:Defining a Variable • To define a variable: (define var-name its-value) • That is, a legal expression is: a left-parenthesis, then the word define, then a previously-undefined name, then a legal expression, then a right-parenthesis.

  5. Syntax Rule #5 • As described in words on page 58, to define a function, you need to type: (define (func-name param-name …) expression)) • The first one, func-name, needs to be an identifier that has not been used before. • The others, param-names, can be any identifier, as long as you do not use the same one twice in the same function.

More Related