{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# notes01 - even non-expression sentences(first 274 functions...

This preview shows page 1. Sign up to view the full content.

CS 61A Lecture Notes Week 1 Topic: Functional programming Reading: Abelson & Sussman, Section 1.1 (pages 1–31) Welcome to CS 61A, the world’s best computer science course, because we use the world’s best CS book as the textbook. The only thing wrong with this course is that all the rest of the CS courses for the rest of your life will seem a little disappointing (and repetitive). Course overview comes next lecture; now we’re going to jump right in so you can get started exploring on your own in the lab. In 61A we program in Scheme, which is an interactive language. That means that instead of writing a great big program and then cranking it through all at once, you can type in a single expression and find out its value. For example: 3 self-evaluating (+ 2 3) function notation (sqrt 16) names don’t have to be punctuation (+ (* 3 4) 5) composition of functions + functions are things in themselves ’+ quoting ’hello can quote any word ’(+ 2 3) can quote any expression ’(good morning)
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: even non-expression sentences (first 274) functions don’t have to be arithmetic (butfirst 274) (abbreviation bf ) (first ’hello) works for non-numbers (first hello) reminder about quoting (first (bf ’hello)) composition of non-numeric functions (+ (first 23) (last 45)) combining numeric and non-numeric (define pi 3.14159) special form pi value of a symbol ’pi contrast with quoted symbol (+ pi 7) symbols work in larger expressions (* pi pi) (define (square x) (* x x)) de±ning a function (square 5) invoking the function (square (+ 2 3)) composition with de±ned functions Terminology: the formal parameter is the name of the argument ( x ); the actual argument expression is the expression used in the invocation ( (+ 2 3) ); the actual argument value is the value of the argument in the invocation (5). The argument’s name comes from the function’s de±nition; the argument’s value comes from the invocation. 267...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online