Composite types Cartesian products –tuples, records, structures disjoint unions –union, discriminated or variant records mappings –arrays, functions recursive.

Slides:



Advertisements
Similar presentations
Types and Programming Languages Lecture 8 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Advertisements

Chapter 10 C Structures, Unions, Bit Manipulations, and Enumerations.
Enumerated data type & typedef. Enumerated Data Type An enumeration consists of a set of named integer constants. An enumeration type declaration gives.
ENUMERATED, typedef. ENUMERATED DATA TYPES An enumeration consists of a set of named integer constants. An enumeration type declaration gives the name.
Line Efficiency     Percentage Month Today’s Date
Unit Number Oct 2011 Nov 2011 Dec 2011 Jan 2012 Feb 2012 Mar 2012 Apr 2012 May 2012 Jun 2012 Jul 2012 Aug 2012 Sep (3/4 Unit) 7 8 Units.
Types A type consists of –a set of values –a set of operations on those values Types can be –primitive (atomic, non-decomposable) –composite (includes.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 10 - Structures, Unions, Bit Manipulations, and Enumerations Outline 10.1Introduction 10.2Structure.
1 COMP313A Programming Languages Data Types (2). 2 Overview Type Constructors Type Equivalence Type Checking Type Conversion.
1 Section 1.6 Sets. 2 Set Fundamental discrete structure on which all other discrete structures are built Can be loosely defined as a collection of elements.
ProjectImpactResourcesDeadlineResourcesDeadline Forecast Plan Time Resources Risk 001xx 002xx 003xx 004xx 005xx 006xx 007xx TotalXX Example 1: Portfolio.
What do I need to Know For My Assignment?. C Pointer Review To declare a pointer, we use the * operator. This is similar to but different from using *
2-1 © 2004, D.A. Watt, University of Glasgow 2 Values and Types  Types of values.  Primitive, composite, recursive types.  Type systems: static vs dynamic.
Windows Server 2008 R2 Oct 2009 Windows Server 2003
SPOUSE LEADERSHIP DEVELOPMENT COURSE (SLDC) CLASS 68
Jan 2016 Solar Lunar Data.
IT Strategy Roadmap Template

Analyzing patterns in the phenomena
Q1 Jan Feb Mar ENTER TEXT HERE Notes

Project timeline # 3 Step # 3 is about x, y and z # 2
Average Monthly Temperature and Rainfall
80-Hour SHARP Certification Course Schedule


Mammoth Caves National Park, Kentucky
2017 Jan Sun Mon Tue Wed Thu Fri Sat
Timeline PowerPoint Template

Gantt Chart Enter Year Here Activities Jan Feb Mar Apr May Jun Jul Aug
Q1 Q2 Q3 Q4 PRODUCT ROADMAP TITLE Roadmap Tagline MILESTONE MILESTONE
Free PPT Diagrams : ALLPPT.com

Proposed Strategic Planning Process for FY 2013/14 thru FY 2015/16

Wireless Local Number Portability Timeline - Phase 2
Step 3 Step 2 Step 1 Put your text here Put your text here
Calendar Year 2009 Insure Oklahoma Total & Projected Enrollment
MONTH CYCLE BEGINS CYCLE ENDS DUE TO FINANCE JUL /2/2015
Jan Sun Mon Tue Wed Thu Fri Sat

©G Dear 2008 – Not to be sold/Free to use
C Structures, Unions, Bit Manipulations and Enumerations
Electricity Cost and Use – FY 2016 and FY 2017

Safety Group Program Timeline
Unemployment in Today’s Economy
Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
Q1 Q2 Q3 Q4 PRODUCT ROADMAP TITLE Roadmap Tagline MILESTONE MILESTONE
Free PPT Diagrams : ALLPPT.com


Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
Belem Climate Data Table
Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
Project timeline # 3 Step # 3 is about x, y and z # 2
TIMELINE NAME OF PROJECT Today 2016 Jan Feb Mar Apr May Jun
Safety Group Program Timeline
Wireless Local Number Portability Timeline - Phase 2

Q1 Q2 Q3 Q4 PRODUCT ROADMAP TITLE Roadmap Tagline MILESTONE MILESTONE
Pilot of revised survey
Presentation transcript:

Composite types Cartesian products –tuples, records, structures disjoint unions –union, discriminated or variant records mappings –arrays, functions recursive types –lists, trees

Cartesian products S x T = {(x,y) | x in S, y in T} Basic operations: –construction of a pair –selection of a component Cardinality (#) of a Cartesian product: –#(S x T) = #S * #T Can be extended naturally beyond pairs to general n-tuples

C structures enum Month {jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec}; struct Date { Month m; int d; }; Date today = {mar,6};

Pascal records month = (jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec); date = record m: month; d: 1..31; end; today : date; today.m := mar; today.d := 6;

ML records Form of record: { :, :,... : } Accessing a member: # ( ) datatype month = jan | feb | mar | apr | may | jun | jul | aug | sep | oct | nov | dec; val today = { m=mar, d=6 };

ML tuples A tuple in ML is a special type of record, whose field labels are integers starting from 1. (“fred”,false) is a tuple whose type is reported as string * bool. This is underlyingly the record { 1=“fred”, 2=false }, but the (…) are special syntactic sugar.

Tuples and records in ML val a = (“fred”, false) has type string*bool. val b = {1=“fred”, 2=false) has type string*bool, and is printed as (“fred”,false). val c = {one=“fred”, two=false} has type {one:string, two:bool} and is printed as {one=“fred”, two=false}.

Making a date in ML datatype month = jan | feb | mar | apr | may | jun | jul | aug | sep | oct | nov | dec; datatype date = Date of month * int; val today = Date(mar,6); Date is a new type which is built using a tuple, a special type of record.

Accessing members of a datatype val today = Date(mar,6); val Date(x,y) = today; This binds x to mar and y to 6!

ML interaction Showed how to define a record Showed that a tuple is a record with special field labels Showed how record member access works with # ( ) Defined datatype for month Showed use of datatype constructor