SlideShare a Scribd company logo
9.1 Assignment
The set! (pronounced "set-bang!") special form associates a new value with an already
defined name.
The exclamation point at the end of set! follows a naming convention to indicate that an
operation may mutate state.
A set expression is also known as an assignment. It assigns a value to a
variable. The grammar rule for assignment is:
The evaluation rule for an assignment is:
Evaluation Rule 7: Assignment. To evaluate an assignment, evaluate
the expression, and replace the value associated with the name with the value of
the expression. An assignment has no value.
Assignments do not produce output values, but are used for their side effects.
They change the value of some state (namely, the value associated with the name in the
set expression), but do not produce an output.
Here is an example use of set!:
> (define num 200)
> num 200
> (set! num 150)
> (set! num 1120)
> num 1120
Begin expression. Since assignments do not evaluate to a value, they are often used
inside a begin expression.
A begin expression is a special form that evaluates a sequence of expressions in order
and evaluates to the value of the last expression.
The grammar rule for the begin expression is:
The evaluation rule is: Evaluation Rule 8: Begin. To evaluate a begin expression,
(begin Expression1 Expression2… Expressionk)(begin Expression1 Expressio
n2… Expressionk)
evaluate each subexpression in order from left to right. The value of the begin
expression is the value of the last subexpression, ExpressionkExpressionk.
The values of all the subexpressions except the last one are ignored; these
subexpressions are only evaluated for their side effects.
The begin expression must be a special form. It is not possible to define a procedure that
behaves identically to a begin expression since the application rule does not specify the
order in which the operand subexpressions are evaluated.
The definition syntax for procedures includes a hidden begin expression.
(define (Name Parameters) MoreExpressions Expression)
is an abbreviation for:
(define Name
(lambda (Parameters) (begin MoreExpressions Expression)))
The let expression introduced in Section 8.1.1 also includes a hidden begin expression.
(let ((Name1 Expression1)( Name2 Expression2)⋯( Namek Expressionk)
)MoreExpressions Expression)(let ((Name1 Expression1)( Name2 Expression2)
⋯( Namek Expressionk))MoreExpressions Expression)
is equivalent to the application expression:
((lambda( Name1 Name2… Name2)(begin MoreExpressions Expressio
n)) Expression1 Expression2… Expressionk)

More Related Content

PDF
First order partial differential equations
PDF
Formation of partial differential equations by eliminating arbitrary functions
PDF
Java Basic Operators
PPTX
Sorting two numbers
PPTX
LINUX:Control statements in shell programming
PPT
operator
PPTX
DOCX
Normalization
First order partial differential equations
Formation of partial differential equations by eliminating arbitrary functions
Java Basic Operators
Sorting two numbers
LINUX:Control statements in shell programming
operator
Normalization

What's hot (18)

PDF
Relational algebra
PPT
expressions
PPTX
PPTX
relational algebra-(basics)
PPTX
Basic Calculus Lesson 1
PPTX
Regular Expression Crash Course
PDF
Handout # 4 functions + scopes
PPTX
Operators in java
PPT
Selection Sort - Vipin Ramola
PPTX
relational algebra (joins)
PPTX
Operator Precedence and Associativity
PDF
DOCX
Ms excel formulas
PDF
Database normalization
PPTX
Regular expression for dfa
PPTX
PPTX
Iv unit-rule rule base
PPTX
Operators , Functions and Options in VB.NET
Relational algebra
expressions
relational algebra-(basics)
Basic Calculus Lesson 1
Regular Expression Crash Course
Handout # 4 functions + scopes
Operators in java
Selection Sort - Vipin Ramola
relational algebra (joins)
Operator Precedence and Associativity
Ms excel formulas
Database normalization
Regular expression for dfa
Iv unit-rule rule base
Operators , Functions and Options in VB.NET
Ad

Viewers also liked (19)

PPT
pairs
PPT
python
PPT
lists
PPT
impact of_mutation
PPT
1.2 eye & vision
PPT
Array- queues3
PPT
Stacks queues
PPT
empirical masurements
PPT
Lighting for displays and signaling
PPT
evaluating recursive_applications
PPT
Flood & sports
PPT
Transport lighting
PPT
Quick sort
PPT
Pda to cfg h2
PDF
Multi dimensional array
PPT
Shell sort
PPT
Np completeness h4
PPT
Two dimensional array
PPT
Turing Machine
pairs
python
lists
impact of_mutation
1.2 eye & vision
Array- queues3
Stacks queues
empirical masurements
Lighting for displays and signaling
evaluating recursive_applications
Flood & sports
Transport lighting
Quick sort
Pda to cfg h2
Multi dimensional array
Shell sort
Np completeness h4
Two dimensional array
Turing Machine
Ad

Similar to assignment (20)

PPT
decisions
PPT
evaluation rules
PPT
E212d9a797dbms chapter3 b.sc2
PPT
E212d9a797dbms chapter3 b.sc2 (1)
PPT
E212d9a797dbms chapter3 b.sc2 (2)
PPTX
Flow of control by deepak lakhlan
PPTX
functions in python By Eng. Osama Ghandour الدوال فى البايثون مع مهندس اسامه ...
PPT
Relational-algebra in Data base management ppts
PDF
Assignment 4
PPTX
Functions in python slide share
PPT
Chapter 5 -Syntax Directed Translation - Copy.ppt
PPTX
LISP:Control Structures In Lisp
PPTX
LISP: Control Structures In Lisp
PDF
DBMS Module 2.2.pdf......................
PPT
Adv. python regular expression by Rj
PPT
Module 2-2.ppt
PPTX
c programming2.pptx
PDF
Programming in C Session 1
PPT
Shubhrat operator & expression
decisions
evaluation rules
E212d9a797dbms chapter3 b.sc2
E212d9a797dbms chapter3 b.sc2 (1)
E212d9a797dbms chapter3 b.sc2 (2)
Flow of control by deepak lakhlan
functions in python By Eng. Osama Ghandour الدوال فى البايثون مع مهندس اسامه ...
Relational-algebra in Data base management ppts
Assignment 4
Functions in python slide share
Chapter 5 -Syntax Directed Translation - Copy.ppt
LISP:Control Structures In Lisp
LISP: Control Structures In Lisp
DBMS Module 2.2.pdf......................
Adv. python regular expression by Rj
Module 2-2.ppt
c programming2.pptx
Programming in C Session 1
Shubhrat operator & expression

More from Rajendran (20)

PPT
Element distinctness lower bounds
PPT
Scheduling with Startup and Holding Costs
PPT
Divide and conquer surfing lower bounds
PPT
Red black tree
PPT
Hash table
PPT
Medians and order statistics
PPT
Proof master theorem
PPT
Recursion tree method
PPT
Recurrence theorem
PPT
Master method
PPT
Master method theorem
PPT
Hash tables
PPT
Lower bound
PPT
Master method theorem
PPT
Greedy algorithms
PPT
Longest common subsequences in Algorithm Analysis
PPT
Dynamic programming in Algorithm Analysis
PPT
Average case Analysis of Quicksort
PPT
Np completeness
PPT
computer languages
Element distinctness lower bounds
Scheduling with Startup and Holding Costs
Divide and conquer surfing lower bounds
Red black tree
Hash table
Medians and order statistics
Proof master theorem
Recursion tree method
Recurrence theorem
Master method
Master method theorem
Hash tables
Lower bound
Master method theorem
Greedy algorithms
Longest common subsequences in Algorithm Analysis
Dynamic programming in Algorithm Analysis
Average case Analysis of Quicksort
Np completeness
computer languages

Recently uploaded (20)

PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Presentation on HIE in infants and its manifestations
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PPTX
Cell Types and Its function , kingdom of life
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Computing-Curriculum for Schools in Ghana
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
01-Introduction-to-Information-Management.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
Presentation on HIE in infants and its manifestations
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Cell Types and Its function , kingdom of life
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
Supply Chain Operations Speaking Notes -ICLT Program
Computing-Curriculum for Schools in Ghana
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Final Presentation General Medicine 03-08-2024.pptx
01-Introduction-to-Information-Management.pdf
VCE English Exam - Section C Student Revision Booklet
Abdominal Access Techniques with Prof. Dr. R K Mishra
2.FourierTransform-ShortQuestionswithAnswers.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Microbial diseases, their pathogenesis and prophylaxis
Final Presentation General Medicine 03-08-2024.pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf

assignment

  • 1. 9.1 Assignment The set! (pronounced "set-bang!") special form associates a new value with an already defined name. The exclamation point at the end of set! follows a naming convention to indicate that an operation may mutate state. A set expression is also known as an assignment. It assigns a value to a variable. The grammar rule for assignment is: The evaluation rule for an assignment is: Evaluation Rule 7: Assignment. To evaluate an assignment, evaluate the expression, and replace the value associated with the name with the value of the expression. An assignment has no value.
  • 2. Assignments do not produce output values, but are used for their side effects. They change the value of some state (namely, the value associated with the name in the set expression), but do not produce an output. Here is an example use of set!: > (define num 200) > num 200 > (set! num 150) > (set! num 1120) > num 1120 Begin expression. Since assignments do not evaluate to a value, they are often used inside a begin expression. A begin expression is a special form that evaluates a sequence of expressions in order and evaluates to the value of the last expression. The grammar rule for the begin expression is: The evaluation rule is: Evaluation Rule 8: Begin. To evaluate a begin expression, (begin Expression1 Expression2… Expressionk)(begin Expression1 Expressio n2… Expressionk)
  • 3. evaluate each subexpression in order from left to right. The value of the begin expression is the value of the last subexpression, ExpressionkExpressionk. The values of all the subexpressions except the last one are ignored; these subexpressions are only evaluated for their side effects. The begin expression must be a special form. It is not possible to define a procedure that behaves identically to a begin expression since the application rule does not specify the order in which the operand subexpressions are evaluated. The definition syntax for procedures includes a hidden begin expression. (define (Name Parameters) MoreExpressions Expression) is an abbreviation for: (define Name (lambda (Parameters) (begin MoreExpressions Expression))) The let expression introduced in Section 8.1.1 also includes a hidden begin expression. (let ((Name1 Expression1)( Name2 Expression2)⋯( Namek Expressionk) )MoreExpressions Expression)(let ((Name1 Expression1)( Name2 Expression2) ⋯( Namek Expressionk))MoreExpressions Expression) is equivalent to the application expression: ((lambda( Name1 Name2… Name2)(begin MoreExpressions Expressio n)) Expression1 Expression2… Expressionk)