notes01 - even non-expression sentences (first 274)...

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

View Full Document Right Arrow Icon
CS 61A Lecture Notes Week 1 Topic: Functional programming Reading: 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 ±nd 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)
Background image of page 1
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 dont 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)) dening a function (square 5) invoking the function (square (+ 2 3)) composition with dened 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 arguments name comes from the functions denition; the arguments value comes from the invocation. 267...
View Full Document

This note was uploaded on 02/17/2010 for the course COMPUTER S 26275 taught by Professor Harvey,b during the Spring '10 term at University of California, Berkeley.

Ask a homework question - tutors are online