SlideShare a Scribd company logo
1 of 3
5.1 Types
All data in a program has an associated type. Internally, all data is stored just as
a sequence of bits, so the type of the data is important to understand what it means.
We have seen several different types of data already: Numbers, Booleans,
and Procedures (we use initial capital letters to signify a datatype).
A datatype defines a set (often infinite) of possible values. The Boolean datatype
contains the two Boolean values, true and false.
The Number type includes the infinite set of all whole numbers (it also includes negative
numbers and rational numbers).
We think of the set of possible Numbers as infinite, even though on any
particular computer there is some limit to the amount of memory available, and
hence, some largest number that can be represented.
On any real computer, the number of possible values of any data type is always finite.
But, we can imagine a computer large enough to represent any given number.
The type of a value determines what can be done with it.
For example, a Number can be used as one of the inputs to the primitive procedures +, *,
and =. A Boolean can be used as the first subexpression of an if expression and as the
input to the not procedure (not can also take a Number as its input, but for all Number
value inputs the output is false), but cannot be used as the input to +, *, or =.1
A Procedure can be the first subexpression in an application expression. There
are infinitely many different types of Procedures, since the type of a Procedure depends
on its input and output types. For example, recall bigger procedure from Chapter 3:
bigger (define (bigger a b) (if ( > a b) a b))
It takes two Numbers as input and produces a Number as output. We denote this type
as:
Number ×× Number →→ Number
The inputs to the procedure are shown on the left side of the arrow. The type of each
input is shown in order, separated by the ×× symbol.2 The output type is given on the
right side of the arrow.
From its definition, it is clear that the bigger procedure takes two inputs from its
parameter list. How do we know the inputs must be Numbers and the output is
a Number?
The body of the bigger procedure is an if expression with the predicate expression (> a
b). This applies the > primitive procedure to the two inputs.
The type of the > procedure is Number ×× Number →→ Boolean.
So, for the predicate expression to be valid, its inputs must both be Numbers.
This means the input values to bigger must both be Numbers.
We know the output of the bigger procedure will be a Number by analyzing the
consequent and alternate subexpressions: each evaluates to one of the input
values, which must be a Number.
Starting with the primitive Boolean, Number, and Procedure types, we can build
arbitrarily complex datatypes.
This chapter introduces mechanisms for building complex datatypes by combining the
primitive datatypes.
Exercise 5.1 Describe the type of each of these expressions.
1.17
2.
3.
4.
5.
(lambda (a) (> a 0))
((lambda (a) (> a 0)) 3)
(lambda (a) (lambda (b) ( > a
b))) (lambda (a) a)
Exercise 5.2 Define or identify a procedure that has the given type.
1.Number ×× Number →→ Boolean
2.
3.
Nu
mbe
r) 4.
Number →→ Number
(Number →→ Number) ×× (Number →→ Number) →→ (Number
→→
Number →→ (Number →→ (Number →→ Number))

More Related Content

What's hot

Programming Problem 3
Programming Problem 3Programming Problem 3
Programming Problem 3Dwight Sabio
 
13. Pointer and 2D array
13. Pointer  and  2D array13. Pointer  and  2D array
13. Pointer and 2D arrayGem WeBlog
 
Data types and operators
Data types and operatorsData types and operators
Data types and operatorsamukthamalya
 
Introduction To Programming with Python-4
Introduction To Programming with Python-4Introduction To Programming with Python-4
Introduction To Programming with Python-4Syed Farjad Zia Zaidi
 
Write a function called float dotproduct (links to an external site.)(float a...
Write a function called float dotproduct (links to an external site.)(float a...Write a function called float dotproduct (links to an external site.)(float a...
Write a function called float dotproduct (links to an external site.)(float a...JenniferBall48
 
Enumerated data types
Enumerated data typesEnumerated data types
Enumerated data typesAnkit Sinha
 
Data types in python lecture (2)
Data types in python lecture (2)Data types in python lecture (2)
Data types in python lecture (2)Ali ٍSattar
 

What's hot (13)

Programming Problem 3
Programming Problem 3Programming Problem 3
Programming Problem 3
 
Ppt lesson 08
Ppt lesson 08Ppt lesson 08
Ppt lesson 08
 
hash
 hash hash
hash
 
13. Pointer and 2D array
13. Pointer  and  2D array13. Pointer  and  2D array
13. Pointer and 2D array
 
Operators
OperatorsOperators
Operators
 
06 Jo P June 07
06 Jo P June 0706 Jo P June 07
06 Jo P June 07
 
Ppt lesson 07
Ppt lesson 07Ppt lesson 07
Ppt lesson 07
 
Data types and operators
Data types and operatorsData types and operators
Data types and operators
 
Introduction To Programming with Python-4
Introduction To Programming with Python-4Introduction To Programming with Python-4
Introduction To Programming with Python-4
 
Write a function called float dotproduct (links to an external site.)(float a...
Write a function called float dotproduct (links to an external site.)(float a...Write a function called float dotproduct (links to an external site.)(float a...
Write a function called float dotproduct (links to an external site.)(float a...
 
Enumerated data types
Enumerated data typesEnumerated data types
Enumerated data types
 
Data types in python lecture (2)
Data types in python lecture (2)Data types in python lecture (2)
Data types in python lecture (2)
 
Basic python part 1
Basic python part 1Basic python part 1
Basic python part 1
 

Viewers also liked

Công ty tổ chức sự kiện chuyên nghiệp,khánh thành, khai trương, đại hội cổ đô...
Công ty tổ chức sự kiện chuyên nghiệp,khánh thành, khai trương, đại hội cổ đô...Công ty tổ chức sự kiện chuyên nghiệp,khánh thành, khai trương, đại hội cổ đô...
Công ty tổ chức sự kiện chuyên nghiệp,khánh thành, khai trương, đại hội cổ đô...Tien Thao
 
Presentacion eventpadel
Presentacion eventpadelPresentacion eventpadel
Presentacion eventpadeleventpadel
 
Modulo a la introduccion
Modulo a la introduccionModulo a la introduccion
Modulo a la introducciondianitaca
 
Casos sin resolver
Casos sin resolverCasos sin resolver
Casos sin resolverlocas0309
 
Remote control based home appliance control system
Remote control based home appliance control systemRemote control based home appliance control system
Remote control based home appliance control systemJagadeesh Yadav
 
Management manual for a start up entrepreneur - managing teams and leading ne...
Management manual for a start up entrepreneur - managing teams and leading ne...Management manual for a start up entrepreneur - managing teams and leading ne...
Management manual for a start up entrepreneur - managing teams and leading ne...Charles Pozzo di Borgo
 
Ashford samariaposter2009
Ashford samariaposter2009Ashford samariaposter2009
Ashford samariaposter2009SaMaria Hughes
 
Resume Fall 2016 Calton Zheng
Resume Fall 2016 Calton ZhengResume Fall 2016 Calton Zheng
Resume Fall 2016 Calton ZhengCalton Zheng
 
Sponsorship Proposal - Indonesia Human Capital Summit 2016
Sponsorship Proposal - Indonesia Human Capital Summit 2016Sponsorship Proposal - Indonesia Human Capital Summit 2016
Sponsorship Proposal - Indonesia Human Capital Summit 2016Indonesia Human Capital Summit
 
Ventajas y desventajas de la tecnologia en General
Ventajas y desventajas de la tecnologia en GeneralVentajas y desventajas de la tecnologia en General
Ventajas y desventajas de la tecnologia en GeneralBreyner Otero
 

Viewers also liked (15)

Công ty tổ chức sự kiện chuyên nghiệp,khánh thành, khai trương, đại hội cổ đô...
Công ty tổ chức sự kiện chuyên nghiệp,khánh thành, khai trương, đại hội cổ đô...Công ty tổ chức sự kiện chuyên nghiệp,khánh thành, khai trương, đại hội cổ đô...
Công ty tổ chức sự kiện chuyên nghiệp,khánh thành, khai trương, đại hội cổ đô...
 
AHTS Penguin1 FOR SALE
AHTS Penguin1 FOR SALEAHTS Penguin1 FOR SALE
AHTS Penguin1 FOR SALE
 
Presentacion eventpadel
Presentacion eventpadelPresentacion eventpadel
Presentacion eventpadel
 
Modulo a la introduccion
Modulo a la introduccionModulo a la introduccion
Modulo a la introduccion
 
Segundo Parcial
Segundo ParcialSegundo Parcial
Segundo Parcial
 
Casos sin resolver
Casos sin resolverCasos sin resolver
Casos sin resolver
 
Remote control based home appliance control system
Remote control based home appliance control systemRemote control based home appliance control system
Remote control based home appliance control system
 
Management manual for a start up entrepreneur - managing teams and leading ne...
Management manual for a start up entrepreneur - managing teams and leading ne...Management manual for a start up entrepreneur - managing teams and leading ne...
Management manual for a start up entrepreneur - managing teams and leading ne...
 
Ashford samariaposter2009
Ashford samariaposter2009Ashford samariaposter2009
Ashford samariaposter2009
 
Nanang Sjahrian Nur's Resume
Nanang Sjahrian Nur's ResumeNanang Sjahrian Nur's Resume
Nanang Sjahrian Nur's Resume
 
Consulta y operación en access
Consulta y operación en accessConsulta y operación en access
Consulta y operación en access
 
List moderate
List   moderateList   moderate
List moderate
 
Resume Fall 2016 Calton Zheng
Resume Fall 2016 Calton ZhengResume Fall 2016 Calton Zheng
Resume Fall 2016 Calton Zheng
 
Sponsorship Proposal - Indonesia Human Capital Summit 2016
Sponsorship Proposal - Indonesia Human Capital Summit 2016Sponsorship Proposal - Indonesia Human Capital Summit 2016
Sponsorship Proposal - Indonesia Human Capital Summit 2016
 
Ventajas y desventajas de la tecnologia en General
Ventajas y desventajas de la tecnologia en GeneralVentajas y desventajas de la tecnologia en General
Ventajas y desventajas de la tecnologia en General
 

Similar to types

CP4151 Advanced data structures and algorithms
CP4151 Advanced data structures and algorithmsCP4151 Advanced data structures and algorithms
CP4151 Advanced data structures and algorithmsSheba41
 
Ap Power Point Chpt2
Ap Power Point Chpt2Ap Power Point Chpt2
Ap Power Point Chpt2dplunkett
 
Discrete structure ch 3 short question's
Discrete structure ch 3 short question'sDiscrete structure ch 3 short question's
Discrete structure ch 3 short question'shammad463061
 
9 big o-notation
9 big o-notation9 big o-notation
9 big o-notationirdginfo
 
Lesson 13. Pattern 5. Address arithmetic
Lesson 13. Pattern 5. Address arithmeticLesson 13. Pattern 5. Address arithmetic
Lesson 13. Pattern 5. Address arithmeticPVS-Studio
 
data type.pptxddddswwyertr hai na ki extend kr de la
data type.pptxddddswwyertr hai na ki extend kr de ladata type.pptxddddswwyertr hai na ki extend kr de la
data type.pptxddddswwyertr hai na ki extend kr de laLEOFAKE
 
TOPIC-2-Expression Variable Assignment Statement.pdf
TOPIC-2-Expression Variable Assignment Statement.pdfTOPIC-2-Expression Variable Assignment Statement.pdf
TOPIC-2-Expression Variable Assignment Statement.pdfEjazAlam23
 
VCE Unit 01 (2).pptx
VCE Unit 01 (2).pptxVCE Unit 01 (2).pptx
VCE Unit 01 (2).pptxskilljiolms
 
analyzing procedures
analyzing proceduresanalyzing procedures
analyzing proceduresRajendran
 
Oop with c++ notes unit 01 introduction
Oop with c++ notes   unit 01 introductionOop with c++ notes   unit 01 introduction
Oop with c++ notes unit 01 introductionAnanda Kumar HN
 
Java căn bản - Chapter3
Java căn bản - Chapter3Java căn bản - Chapter3
Java căn bản - Chapter3Vince Vo
 
UNIT-II VISUAL BASIC.NET | BCA
UNIT-II VISUAL BASIC.NET | BCAUNIT-II VISUAL BASIC.NET | BCA
UNIT-II VISUAL BASIC.NET | BCARaj vardhan
 
Physics investigatory project for class 12 logic gates
Physics investigatory project for class 12 logic gatesPhysics investigatory project for class 12 logic gates
Physics investigatory project for class 12 logic gatesbiswanath dehuri
 
chapter one && two.pdf
chapter one && two.pdfchapter one && two.pdf
chapter one && two.pdfmiftah88
 

Similar to types (20)

CP4151 Advanced data structures and algorithms
CP4151 Advanced data structures and algorithmsCP4151 Advanced data structures and algorithms
CP4151 Advanced data structures and algorithms
 
Ap Power Point Chpt2
Ap Power Point Chpt2Ap Power Point Chpt2
Ap Power Point Chpt2
 
C program
C programC program
C program
 
Discrete structure ch 3 short question's
Discrete structure ch 3 short question'sDiscrete structure ch 3 short question's
Discrete structure ch 3 short question's
 
Data Transformation
Data TransformationData Transformation
Data Transformation
 
Daa chapter 1
Daa chapter 1Daa chapter 1
Daa chapter 1
 
9 big o-notation
9 big o-notation9 big o-notation
9 big o-notation
 
Lesson 13. Pattern 5. Address arithmetic
Lesson 13. Pattern 5. Address arithmeticLesson 13. Pattern 5. Address arithmetic
Lesson 13. Pattern 5. Address arithmetic
 
data type.pptxddddswwyertr hai na ki extend kr de la
data type.pptxddddswwyertr hai na ki extend kr de ladata type.pptxddddswwyertr hai na ki extend kr de la
data type.pptxddddswwyertr hai na ki extend kr de la
 
TOPIC-2-Expression Variable Assignment Statement.pdf
TOPIC-2-Expression Variable Assignment Statement.pdfTOPIC-2-Expression Variable Assignment Statement.pdf
TOPIC-2-Expression Variable Assignment Statement.pdf
 
VCE Unit 01 (2).pptx
VCE Unit 01 (2).pptxVCE Unit 01 (2).pptx
VCE Unit 01 (2).pptx
 
analyzing procedures
analyzing proceduresanalyzing procedures
analyzing procedures
 
Oop with c++ notes unit 01 introduction
Oop with c++ notes   unit 01 introductionOop with c++ notes   unit 01 introduction
Oop with c++ notes unit 01 introduction
 
Java căn bản - Chapter3
Java căn bản - Chapter3Java căn bản - Chapter3
Java căn bản - Chapter3
 
expressions
expressionsexpressions
expressions
 
UNIT-II VISUAL BASIC.NET | BCA
UNIT-II VISUAL BASIC.NET | BCAUNIT-II VISUAL BASIC.NET | BCA
UNIT-II VISUAL BASIC.NET | BCA
 
Algoritmos
AlgoritmosAlgoritmos
Algoritmos
 
Physics investigatory project for class 12 logic gates
Physics investigatory project for class 12 logic gatesPhysics investigatory project for class 12 logic gates
Physics investigatory project for class 12 logic gates
 
chapter one && two.pdf
chapter one && two.pdfchapter one && two.pdf
chapter one && two.pdf
 
ALGO.ppt
ALGO.pptALGO.ppt
ALGO.ppt
 

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

Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
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
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
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
 
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
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
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
 
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
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 

Recently uploaded (20)

Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
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
 
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
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
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🔝
 
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
 
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
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 

types

  • 1. 5.1 Types All data in a program has an associated type. Internally, all data is stored just as a sequence of bits, so the type of the data is important to understand what it means. We have seen several different types of data already: Numbers, Booleans, and Procedures (we use initial capital letters to signify a datatype). A datatype defines a set (often infinite) of possible values. The Boolean datatype contains the two Boolean values, true and false. The Number type includes the infinite set of all whole numbers (it also includes negative numbers and rational numbers). We think of the set of possible Numbers as infinite, even though on any particular computer there is some limit to the amount of memory available, and hence, some largest number that can be represented. On any real computer, the number of possible values of any data type is always finite. But, we can imagine a computer large enough to represent any given number. The type of a value determines what can be done with it. For example, a Number can be used as one of the inputs to the primitive procedures +, *, and =. A Boolean can be used as the first subexpression of an if expression and as the input to the not procedure (not can also take a Number as its input, but for all Number value inputs the output is false), but cannot be used as the input to +, *, or =.1 A Procedure can be the first subexpression in an application expression. There are infinitely many different types of Procedures, since the type of a Procedure depends on its input and output types. For example, recall bigger procedure from Chapter 3:
  • 2. bigger (define (bigger a b) (if ( > a b) a b)) It takes two Numbers as input and produces a Number as output. We denote this type as: Number ×× Number →→ Number The inputs to the procedure are shown on the left side of the arrow. The type of each input is shown in order, separated by the ×× symbol.2 The output type is given on the right side of the arrow. From its definition, it is clear that the bigger procedure takes two inputs from its parameter list. How do we know the inputs must be Numbers and the output is a Number? The body of the bigger procedure is an if expression with the predicate expression (> a b). This applies the > primitive procedure to the two inputs. The type of the > procedure is Number ×× Number →→ Boolean. So, for the predicate expression to be valid, its inputs must both be Numbers. This means the input values to bigger must both be Numbers. We know the output of the bigger procedure will be a Number by analyzing the consequent and alternate subexpressions: each evaluates to one of the input values, which must be a Number. Starting with the primitive Boolean, Number, and Procedure types, we can build arbitrarily complex datatypes.
  • 3. This chapter introduces mechanisms for building complex datatypes by combining the primitive datatypes. Exercise 5.1 Describe the type of each of these expressions. 1.17 2. 3. 4. 5. (lambda (a) (> a 0)) ((lambda (a) (> a 0)) 3) (lambda (a) (lambda (b) ( > a b))) (lambda (a) a) Exercise 5.2 Define or identify a procedure that has the given type. 1.Number ×× Number →→ Boolean 2. 3. Nu mbe r) 4. Number →→ Number (Number →→ Number) ×× (Number →→ Number) →→ (Number →→ Number →→ (Number →→ (Number →→ Number))