CS135 Lecture Notes - Lecture 1: Functional Programming
Document Summary
Imperative: based on frequent changes to data (java, turing, c++) Function: based on the computation of new values rather than the transformation of old ones. Easier to design and reason about programs. Syntax (how to say it), expressiveness (how easy it is to say and understand), and semantics (the meaning of what"s being said) Definition of a function consists of function name and parameters. We evaluate each of the arguments to yield values. Only apply a function when all of its arguments are values (not general expressions). g(4, f(2)) = g(4, 4) = 8. The drracket environment (6 4)(3 + 2) becomes ( ( 6 4) (+ 3 2)) Expressions whose values are not rational numbers are flagged as being inexact. A function definition consists of: a name for the function, a list of parameters, a single body expression. define is a special form (looks like a racket function, but not all of its arguments are evaluated).