ai-lisp - Functional programming Languages And a brief...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
    1 Functional programming  Languages And a brief introduction to Lisp and Scheme
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Pure Functional Languages The concept of assignment is not part of functional  programming 1. no explicit assignment statements 2. variables bound to values only through parameter binding at  functional calls 3. function calls have no side-effects 4. no global state Control flow: functional calls and conditional  expressions no iteration! repetition through  recursion
Background image of page 2
3 Referential transparency Referential transparency : the value of a function  application is independent of the context in which it  occurs i.e., value of f(a, b, c) depends only on the values of f, a, b,  and c value does not depend on global state of computation all variables in function must be local (or parameters)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Pure Functional Languages All storage management is implicit copy semantics needs garbage collection Functions are  first-class values can be passed as arguments can be returned as values of expressions can be put in data structures unnamed functions exist as values Functional languages are simple, elegant, not error- prone, and testable
Background image of page 4
5 FPLs vs imperative languages Imperative programming languages Design is based directly on the von Neumann architecture Efficiency is the primary concern, rather than the suitability  of the language for software development Functional programming languages The design of the functional languages is based on  mathematical functions A solid theoretical basis that is also closer to the user, but  relatively unconcerned with the architecture of the machines  on which programs will run 
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 Lambda expressions A mathematical function is a mapping of members of  one set, called the  domain set , to another set, called  the  range set lambda expression  specifies the parameter(s) and the mapping of a function in the following form λ (x) x * x * x for the function cube (x) = x * x * x Lambda expressions describe  nameless functions
Background image of page 6
7 Lambda expressions Lambda expressions are applied to parameter(s) by  placing the parameter(s) after the expression, as in ( λ (x) x * x * x)(3) which evaluates to 27 What does the following expression evaluate to?   ( λ (x) 2 * x + 3)(2)
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 Functional forms A functional form, or higher-order function, is  one that either takes functions as parameters, yields a function as its result, or both  We consider 3 functional forms: Function composition Construction Apply-to-all
Background image of page 8
9 Function composition A functional form that takes two functions as  parameters and yields a function whose result 
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/20/2011 for the course CS 6810 taught by Professor Hecker during the Spring '10 term at CSU East Bay.

Page1 / 54

ai-lisp - Functional programming Languages And a brief...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online