COMPSCI 61A Lecture 9: CS61A-Lecture 09-16-2016
zogo39484755 and 6 others unlocked
22
COMPSCI 61A Full Course Notes
Verified Note
22 documents
Document Summary
Entries in the completely optional hog contest due monday 9/19 @ 11:59pm. Chance once a week to talk with fellow students and mentor about course concepts. Date: a year, a month, and a day. An abstract data type lets us manipulate compound objects as units. Isolate two parts of any program that uses data: Data abstraction: a methodology by which functions enforce an abstraction barrier between representation and use. Great programmers embrace data abstraction to make their programs more modular. As soon as division occurs, the exact representation may be lost! Assume that we can compose and decompose rational numbers: rational(n, d) returns a rational number x. Called a constructor numer(x) returns the numerator of x. Called a selector denom(x) returns the denominator of x. These functions implement an abstract data type for rational numbers. Unpacking: splits elements of the list so that they can be assigned to other variables. Element selection using the selection operator pair[0], pair[1]