Class Notes (838,347)
Canada (510,861)
CS 135 (34)

CS135 Fall 2013

23 Pages
Unlock Document

Computer Science
CS 135
Sandy Graham

Return to University Notes indexCS135Designing Functional ProgramsInstructorName Sandra Sandy GrahamEmail sandygrahamuwaterloocaOffice MC 6423Office hours Tuesdays in MC 20622063 Thursdays in MC 4065 115215 PMISAinstructional support assistantDrop by the Tutorial Center MC 4065 during the scheduled hours for assistance no appointments needediclickerDo this before every class1 Hold OnOff until power button blinks2 There is an iclicker sticker on the wall says DA Press D and then A3 The Vote Status light should flash greenProgramming Language DesignImperative frequent changes to dataJava C Functional computation of new values rather than changing old onesLISP MLHaskell Erlang Fclosely connected to math easier to reason aboutdesign programsSchemeMember of the LISP family of languagesUsually no side effectsoperations do not affect other onesFunctional languageBasic Scheme forms block comment5inline comment6atom numberabcatom stringStylistically single line comments should use two semicolons however this is not required by the syntaxPrimary aspects of courseDesignAbstractionRefinement of old ideasSyntax expressiveness semanticsCommunication with human and computerFunctionsIn math functions generalize similar expressionsfxx24x2gxyxyFunction consist ofFunction nameParametersAlgebraic expression of parametersApplication of functionf3g56Application supplies arguments the values that correspond to the parametersIn math application is evaluated by substitutionfg56f56f111124112167Evaluation can be done in any ordergg13f2g13f2 or g13f2The Scheme interpreter program that evaluates Scheme code uses a left to right depthfirst evaluation orderinsideout left to rightMath is written in infix notationthe operator is placed between its operands There are also notations known as prefix and postfixnotationoperator before operands and operator after operands respectivelyScheme uses prefix notation Prefix notation needs no order of operations because there is no ambiguityConvert infix to prefix6457What is the last operator to be applied 64 57Repeat process6 45 7This is valid prefix notation but not valid SchemeSince in Scheme arbitrary numbers of operands are supported we need t add brackets to make it explicit6 45 7Conversion is done by moving the last operator to be applied to the beginning of the subexpression until no infix operators remainOperand order remains the samePrefix NotationIf we treat infix operators as functions we dont need to use parentheses to specify order of operations32 infix notation3 2 prefix notationConvert to prefix notation
More Less

Related notes for CS 135

Log In


Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.