SlideShare a Scribd company logo
1 of 3
3.7 Decisions
To make more useful procedures, we need the actions taken to depend on the
input values. For example, we may want a procedure that takes two numbers as inputs
and evaluates to the greater of the two inputs.
To define such a procedure we need a way of making a
decision. The IfExpression expression provides a way of using the result of one
expression to select which of two possible expressions to evaluate:
The IfExpression replacement has three Expression terms. For clarity, we give each
of them names as denoted by the Predicate, Consequent, and Alternate subscripts.
To evaluate an IfExpression,
expression,ExpressionPredicatePredicate.
first evaluate the predicate
If it evaluates to any non-false value, the value of theIfExpression is the
value of ExpressionConsequentConsequent, the consequent expression, and the
alternate expression is not evaluated at all.
If the predicate expression evaluates to false, the value of the IfExpression is the value of
ExpressionAlternateAlternate, the alternate expression, and the consequent expression is
not evaluated at all.
Expression
::⇒⇒
IfExpression
IfExpression
::⇒⇒
(if ExpressionPredicatePredicate
ExpressionConsequentConsequent
ExpressionAlternateAlternate)
The predicate expression determines which of the two following expressions is evaluated
to produce the value of the IfExpression.
If the value of the predicate isanything other than |false|, the consequent expression is
used.
For example, if the predicate evaluates to |true|, to a number, or to a procedure
the consequent expression is evaluated.
The if expression is a special form. This means that although it looks syntactically
identical to an application (that is, it could be an application of a procedure named if), it
is not evaluated as a normal application would be.
Instead, we have a special evaluation rule for if expressions. The reason a special
evaluation rule is needed is because we do not want all the subexpressions to be
evaluated.
With the normal application rule, all the subexpressions are evaluated first, and then the
procedure resulting from the first subexpression is applied to the values resulting from
the others.
With the if special form evaluation rule, the predicate expression is always
evaluated first and only one of the following subexpressions is evaluated depending on
the result of evaluating the predicate expression.
This means an if expression can evaluate to a value even if evaluating one of its
subexpressions would produce an error. For example,
(if ( > 3 4) (* + +) 7)
evaluates to 7 even though evaluating the subexpression (* + +) would produce an error.
Because of the special evaluation rule for if expressions, the consequent expression is
never evaluated.

More Related Content

What's hot

Control Structures in Visual Basic
Control Structures in  Visual BasicControl Structures in  Visual Basic
Control Structures in Visual BasicTushar Jain
 
Specification based or black box techniques 3
Specification based or black box techniques 3Specification based or black box techniques 3
Specification based or black box techniques 3alex swandi
 
Logical expression and logical operators
Logical expression and logical operatorsLogical expression and logical operators
Logical expression and logical operatorsSuneel Dogra
 
Specification based or black box techniques
Specification based or black box techniquesSpecification based or black box techniques
Specification based or black box techniquesM Branikno Ramadhan
 
Specification based or black box techniques
Specification based or black box techniquesSpecification based or black box techniques
Specification based or black box techniquesIrvan Febry
 
Bengkel smartPLS 2011
Bengkel smartPLS 2011Bengkel smartPLS 2011
Bengkel smartPLS 2011Adi Ali
 
Item Analysis: Classical and Beyond
Item Analysis: Classical and BeyondItem Analysis: Classical and Beyond
Item Analysis: Classical and BeyondMhairi Mcalpine
 
Specification based or black box techniques
Specification based or black box techniquesSpecification based or black box techniques
Specification based or black box techniquesYoga Setiawan
 
Attribute grammer
Attribute grammerAttribute grammer
Attribute grammerMd. Al-Amin
 
Specification based or black box techniques
Specification based or black box techniquesSpecification based or black box techniques
Specification based or black box techniquesM Branikno Ramadhan
 
Specification based or black box techniques
Specification based or black box techniquesSpecification based or black box techniques
Specification based or black box techniquesAji Pamungkas Prasetio
 
Specification based or black box techniques
Specification based or black box techniquesSpecification based or black box techniques
Specification based or black box techniquesmuhammad afif
 
Participation Constraints in ER diagram
Participation Constraints in ER diagramParticipation Constraints in ER diagram
Participation Constraints in ER diagramMegha Sharma
 
Control structures i
Control structures i Control structures i
Control structures i Ahmad Idrees
 

What's hot (20)

Mathematical modeling
Mathematical modelingMathematical modeling
Mathematical modeling
 
Dbms.....SQL statemets
Dbms.....SQL statemetsDbms.....SQL statemets
Dbms.....SQL statemets
 
Control Structures in Visual Basic
Control Structures in  Visual BasicControl Structures in  Visual Basic
Control Structures in Visual Basic
 
Math Module 4 Review
Math Module 4 ReviewMath Module 4 Review
Math Module 4 Review
 
Ternary operator
Ternary operatorTernary operator
Ternary operator
 
Specification based or black box techniques 3
Specification based or black box techniques 3Specification based or black box techniques 3
Specification based or black box techniques 3
 
Logical expression and logical operators
Logical expression and logical operatorsLogical expression and logical operators
Logical expression and logical operators
 
Specification based or black box techniques
Specification based or black box techniquesSpecification based or black box techniques
Specification based or black box techniques
 
Specification based or black box techniques
Specification based or black box techniquesSpecification based or black box techniques
Specification based or black box techniques
 
Bengkel smartPLS 2011
Bengkel smartPLS 2011Bengkel smartPLS 2011
Bengkel smartPLS 2011
 
Item Analysis: Classical and Beyond
Item Analysis: Classical and BeyondItem Analysis: Classical and Beyond
Item Analysis: Classical and Beyond
 
Specification based or black box techniques
Specification based or black box techniquesSpecification based or black box techniques
Specification based or black box techniques
 
Computer Logic
Computer LogicComputer Logic
Computer Logic
 
Attribute grammer
Attribute grammerAttribute grammer
Attribute grammer
 
Specification based or black box techniques
Specification based or black box techniquesSpecification based or black box techniques
Specification based or black box techniques
 
Specification based or black box techniques
Specification based or black box techniquesSpecification based or black box techniques
Specification based or black box techniques
 
Specification based or black box techniques
Specification based or black box techniquesSpecification based or black box techniques
Specification based or black box techniques
 
Participation Constraints in ER diagram
Participation Constraints in ER diagramParticipation Constraints in ER diagram
Participation Constraints in ER diagram
 
Control structures i
Control structures i Control structures i
Control structures i
 
Ms excel formulas
Ms excel formulasMs excel formulas
Ms excel formulas
 

Viewers also liked

developing complex_programs
developing complex_programsdeveloping complex_programs
developing complex_programsRajendran
 
histry of_computing_machines
histry of_computing_machineshistry of_computing_machines
histry of_computing_machinesRajendran
 
Regular expressions h1
Regular expressions h1Regular expressions h1
Regular expressions h1Rajendran
 
1.3 applications, issues
1.3 applications, issues1.3 applications, issues
1.3 applications, issuesRajendran
 
modeling computing
modeling computingmodeling computing
modeling computingRajendran
 
measuring computing_power
measuring computing_powermeasuring computing_power
measuring computing_powerRajendran
 
recursive transition_networks
recursive transition_networksrecursive transition_networks
recursive transition_networksRajendran
 
mutable pairs_and_lists
mutable pairs_and_listsmutable pairs_and_lists
mutable pairs_and_listsRajendran
 
Normal forms cfg
Normal forms   cfgNormal forms   cfg
Normal forms cfgRajendran
 
TM - Techniques
TM - TechniquesTM - Techniques
TM - TechniquesRajendran
 
Pumping lemma for regular set h1
Pumping lemma for regular set h1Pumping lemma for regular set h1
Pumping lemma for regular set h1Rajendran
 
Basics of data structure
Basics of data structureBasics of data structure
Basics of data structureRajendran
 

Viewers also liked (19)

inheritance
inheritanceinheritance
inheritance
 
developing complex_programs
developing complex_programsdeveloping complex_programs
developing complex_programs
 
expressions
expressionsexpressions
expressions
 
histry of_computing_machines
histry of_computing_machineshistry of_computing_machines
histry of_computing_machines
 
processes
processesprocesses
processes
 
Regular expressions h1
Regular expressions h1Regular expressions h1
Regular expressions h1
 
1.3 applications, issues
1.3 applications, issues1.3 applications, issues
1.3 applications, issues
 
languages
languageslanguages
languages
 
modeling computing
modeling computingmodeling computing
modeling computing
 
measuring computing_power
measuring computing_powermeasuring computing_power
measuring computing_power
 
recursive transition_networks
recursive transition_networksrecursive transition_networks
recursive transition_networks
 
mutable pairs_and_lists
mutable pairs_and_listsmutable pairs_and_lists
mutable pairs_and_lists
 
parser
parserparser
parser
 
Binary trees
Binary treesBinary trees
Binary trees
 
Quicksort
QuicksortQuicksort
Quicksort
 
Normal forms cfg
Normal forms   cfgNormal forms   cfg
Normal forms cfg
 
TM - Techniques
TM - TechniquesTM - Techniques
TM - Techniques
 
Pumping lemma for regular set h1
Pumping lemma for regular set h1Pumping lemma for regular set h1
Pumping lemma for regular set h1
 
Basics of data structure
Basics of data structureBasics of data structure
Basics of data structure
 

Similar to decisions

Flow of control by deepak lakhlan
Flow of control by deepak lakhlanFlow of control by deepak lakhlan
Flow of control by deepak lakhlanDeepak Lakhlan
 
11 EXPRESSIONS.pptx
11 EXPRESSIONS.pptx11 EXPRESSIONS.pptx
11 EXPRESSIONS.pptxRodmanCajes
 
Ap Power Point Chpt3 B
Ap Power Point Chpt3 BAp Power Point Chpt3 B
Ap Power Point Chpt3 Bdplunkett
 
Shubhrat operator & expression
Shubhrat operator & expressionShubhrat operator & expression
Shubhrat operator & expressionShubhrat Mishra
 
Ap Power Point Chpt3
Ap Power Point Chpt3Ap Power Point Chpt3
Ap Power Point Chpt3dplunkett
 
OCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & StatementsOCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & Statementsİbrahim Kürce
 
Week 2 – Lecture 3 Making judgements about differences bet.docx
Week 2 – Lecture 3 Making judgements about differences bet.docxWeek 2 – Lecture 3 Making judgements about differences bet.docx
Week 2 – Lecture 3 Making judgements about differences bet.docxcockekeshia
 
Aspect mining and sentiment association
Aspect mining and sentiment associationAspect mining and sentiment association
Aspect mining and sentiment associationKoushik Ramachandra
 
Selection statements
Selection statementsSelection statements
Selection statementsHarsh Dabas
 
This first assignment will focus on coding in Python, applying kno.docx
This first assignment will focus on coding in Python, applying kno.docxThis first assignment will focus on coding in Python, applying kno.docx
This first assignment will focus on coding in Python, applying kno.docxabhi353063
 
Cprogrammingoperator
CprogrammingoperatorCprogrammingoperator
Cprogrammingoperatorteach4uin
 

Similar to decisions (20)

assignment
assignmentassignment
assignment
 
Flow of control by deepak lakhlan
Flow of control by deepak lakhlanFlow of control by deepak lakhlan
Flow of control by deepak lakhlan
 
11 EXPRESSIONS.pptx
11 EXPRESSIONS.pptx11 EXPRESSIONS.pptx
11 EXPRESSIONS.pptx
 
c programming2.pptx
c programming2.pptxc programming2.pptx
c programming2.pptx
 
Ap Power Point Chpt3 B
Ap Power Point Chpt3 BAp Power Point Chpt3 B
Ap Power Point Chpt3 B
 
Shubhrat operator & expression
Shubhrat operator & expressionShubhrat operator & expression
Shubhrat operator & expression
 
If else statement 05 (js)
If else statement 05 (js)If else statement 05 (js)
If else statement 05 (js)
 
slides03.ppt
slides03.pptslides03.ppt
slides03.ppt
 
Ch04
Ch04Ch04
Ch04
 
Ap Power Point Chpt3
Ap Power Point Chpt3Ap Power Point Chpt3
Ap Power Point Chpt3
 
OCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & StatementsOCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & Statements
 
Week 2 – Lecture 3 Making judgements about differences bet.docx
Week 2 – Lecture 3 Making judgements about differences bet.docxWeek 2 – Lecture 3 Making judgements about differences bet.docx
Week 2 – Lecture 3 Making judgements about differences bet.docx
 
Aspect mining and sentiment association
Aspect mining and sentiment associationAspect mining and sentiment association
Aspect mining and sentiment association
 
Selection statements
Selection statementsSelection statements
Selection statements
 
This first assignment will focus on coding in Python, applying kno.docx
This first assignment will focus on coding in Python, applying kno.docxThis first assignment will focus on coding in Python, applying kno.docx
This first assignment will focus on coding in Python, applying kno.docx
 
MODULE_2_Operators.pptx
MODULE_2_Operators.pptxMODULE_2_Operators.pptx
MODULE_2_Operators.pptx
 
Cprogrammingoperator
CprogrammingoperatorCprogrammingoperator
Cprogrammingoperator
 
C# operators
C# operatorsC# operators
C# operators
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
procedures
proceduresprocedures
procedures
 

More from Rajendran

Element distinctness lower bounds
Element distinctness lower boundsElement distinctness lower bounds
Element distinctness lower boundsRajendran
 
Scheduling with Startup and Holding Costs
Scheduling with Startup and Holding CostsScheduling with Startup and Holding Costs
Scheduling with Startup and Holding CostsRajendran
 
Divide and conquer surfing lower bounds
Divide and conquer  surfing lower boundsDivide and conquer  surfing lower bounds
Divide and conquer surfing lower boundsRajendran
 
Red black tree
Red black treeRed black tree
Red black treeRajendran
 
Medians and order statistics
Medians and order statisticsMedians and order statistics
Medians and order statisticsRajendran
 
Proof master theorem
Proof master theoremProof master theorem
Proof master theoremRajendran
 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree methodRajendran
 
Recurrence theorem
Recurrence theoremRecurrence theorem
Recurrence theoremRajendran
 
Master method
Master method Master method
Master method Rajendran
 
Master method theorem
Master method theoremMaster method theorem
Master method theoremRajendran
 
Master method theorem
Master method theoremMaster method theorem
Master method theoremRajendran
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithmsRajendran
 
Longest common subsequences in Algorithm Analysis
Longest common subsequences in Algorithm AnalysisLongest common subsequences in Algorithm Analysis
Longest common subsequences in Algorithm AnalysisRajendran
 
Dynamic programming in Algorithm Analysis
Dynamic programming in Algorithm AnalysisDynamic programming in Algorithm Analysis
Dynamic programming in Algorithm AnalysisRajendran
 
Average case Analysis of Quicksort
Average case Analysis of QuicksortAverage case Analysis of Quicksort
Average case Analysis of QuicksortRajendran
 
Np completeness
Np completenessNp completeness
Np completenessRajendran
 
computer languages
computer languagescomputer languages
computer languagesRajendran
 

More from Rajendran (20)

Element distinctness lower bounds
Element distinctness lower boundsElement distinctness lower bounds
Element distinctness lower bounds
 
Scheduling with Startup and Holding Costs
Scheduling with Startup and Holding CostsScheduling with Startup and Holding Costs
Scheduling with Startup and Holding Costs
 
Divide and conquer surfing lower bounds
Divide and conquer  surfing lower boundsDivide and conquer  surfing lower bounds
Divide and conquer surfing lower bounds
 
Red black tree
Red black treeRed black tree
Red black tree
 
Hash table
Hash tableHash table
Hash table
 
Medians and order statistics
Medians and order statisticsMedians and order statistics
Medians and order statistics
 
Proof master theorem
Proof master theoremProof master theorem
Proof master theorem
 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree method
 
Recurrence theorem
Recurrence theoremRecurrence theorem
Recurrence theorem
 
Master method
Master method Master method
Master method
 
Master method theorem
Master method theoremMaster method theorem
Master method theorem
 
Hash tables
Hash tablesHash tables
Hash tables
 
Lower bound
Lower boundLower bound
Lower bound
 
Master method theorem
Master method theoremMaster method theorem
Master method theorem
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
 
Longest common subsequences in Algorithm Analysis
Longest common subsequences in Algorithm AnalysisLongest common subsequences in Algorithm Analysis
Longest common subsequences in Algorithm Analysis
 
Dynamic programming in Algorithm Analysis
Dynamic programming in Algorithm AnalysisDynamic programming in Algorithm Analysis
Dynamic programming in Algorithm Analysis
 
Average case Analysis of Quicksort
Average case Analysis of QuicksortAverage case Analysis of Quicksort
Average case Analysis of Quicksort
 
Np completeness
Np completenessNp completeness
Np completeness
 
computer languages
computer languagescomputer languages
computer languages
 

Recently uploaded

“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 

Recently uploaded (20)

“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 

decisions

  • 1. 3.7 Decisions To make more useful procedures, we need the actions taken to depend on the input values. For example, we may want a procedure that takes two numbers as inputs and evaluates to the greater of the two inputs. To define such a procedure we need a way of making a decision. The IfExpression expression provides a way of using the result of one expression to select which of two possible expressions to evaluate: The IfExpression replacement has three Expression terms. For clarity, we give each of them names as denoted by the Predicate, Consequent, and Alternate subscripts. To evaluate an IfExpression, expression,ExpressionPredicatePredicate. first evaluate the predicate If it evaluates to any non-false value, the value of theIfExpression is the value of ExpressionConsequentConsequent, the consequent expression, and the alternate expression is not evaluated at all. If the predicate expression evaluates to false, the value of the IfExpression is the value of ExpressionAlternateAlternate, the alternate expression, and the consequent expression is not evaluated at all. Expression ::⇒⇒ IfExpression IfExpression ::⇒⇒ (if ExpressionPredicatePredicate ExpressionConsequentConsequent ExpressionAlternateAlternate)
  • 2. The predicate expression determines which of the two following expressions is evaluated to produce the value of the IfExpression. If the value of the predicate isanything other than |false|, the consequent expression is used. For example, if the predicate evaluates to |true|, to a number, or to a procedure the consequent expression is evaluated. The if expression is a special form. This means that although it looks syntactically identical to an application (that is, it could be an application of a procedure named if), it is not evaluated as a normal application would be. Instead, we have a special evaluation rule for if expressions. The reason a special evaluation rule is needed is because we do not want all the subexpressions to be evaluated. With the normal application rule, all the subexpressions are evaluated first, and then the procedure resulting from the first subexpression is applied to the values resulting from the others. With the if special form evaluation rule, the predicate expression is always evaluated first and only one of the following subexpressions is evaluated depending on the result of evaluating the predicate expression.
  • 3. This means an if expression can evaluate to a value even if evaluating one of its subexpressions would produce an error. For example, (if ( > 3 4) (* + +) 7) evaluates to 7 even though evaluating the subexpression (* + +) would produce an error. Because of the special evaluation rule for if expressions, the consequent expression is never evaluated.