The College of Saint Rose CIS 433 – Programming Languages David Goldschmidt, Ph.D. from Concepts of Programming Languages, 9th edition by Robert W. Sebesta,

Slides:



Advertisements
Similar presentations
1 Copyright © 1998 by Addison Wesley Longman, Inc. Chapter 14 Functional Programming Languages - The design of the imperative languages is based directly.
Advertisements

1 Scheme and Functional Programming Aaron Bloomfield CS 415 Fall 2005.
Lambda Calculus and Lisp PZ03J. Lambda Calculus The lambda calculus is a model for functional programming like Turing machines are models for imperative.
Chapter 3 Functional Programming. Outline Introduction to functional programming Scheme: an untyped functional programming language.
CS 355 – PROGRAMMING LANGUAGES Dr. X. Apply-to-all A functional form that takes a single function as a parameter and yields a list of values obtained.
LISP Programming. LISP – simple and powerful mid-1950’s by John McCarthy at M.I.T. “ LIS t P rocessing language” Artificial Intelligence programs LISP.
1 Functional programming Languages And a brief introduction to Lisp and Scheme.
Functional Programming Languages
ISBN Chapter 1 Preliminaries. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Chapter 1 Topics Motivation Programming Domains.
Chapter 15 Functional Programming Languages. Copyright © 2007 Addison-Wesley. All rights reserved. 1–2 Introduction Design of imperative languages is.
ISBN Chapter 15 Functional Programming Languages Mathematical Functions Fundamentals of Functional Programming Languages Introduction to.
Programming Languages Structure
ISBN Lecture 01 Preliminaries. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Lecture 01 Topics Motivation Programming.
ISBN Chapter 15 Functional Programming Languages.
ISBN Chapter 1 Topics Motivation Programming Domains Language Evaluation Criteria Influences on Language Design Language Categories Language.
ISBN Chapter 15 Functional Programming Languages.
Dr. Muhammed Al-Mulhem ICS An Introduction to Functional Programming.
1 Lisp and Functional Languages Functional forms Referential transparency Function construction Function composition Mapping functions Designing functional.
Lisp by Namtap Tapchareon Lisp Background  Lisp was developed by John McCarthy in  Lisp is derives from List Processing Language. 
The College of Saint Rose CIS 433 – Programming Languages David Goldschmidt, Ph.D. from Concepts of Programming Languages, 9th edition by Robert W. Sebesta,
1 Functional Programming In Text: Chapter Chapter 2: Evolution of the Major Programming Languages Outline Functional programming (FP) basics A bit.
 The design of the imperative languages is based directly on the von Neumann architecture  Efficiency is the primary concern  Low-level specifications:
ISBN Chapter 15 Functional Programming Languages.
ISBN Chapter 15 Functional Programming Languages.
1 Programming Languages and Paradigms Functional Programming.
Copyright © 2007 Addison-Wesley. All rights reserved.1-1 Reasons for Studying Concepts of Programming Languages Increased ability to express ideas Improved.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
LISP John McCarthy and Marvin Minsky formed MIT’s AI Project in Suggested reading: John McCarthy’s home page
Functional Programming Universitatea Politehnica Bucuresti Adina Magda Florea
CHAPTER 15 & 16 Functional & Logic Programming Languages.
Chapter Fifteen: Functional Programming Languages Lesson 12.
ISBN Chapter 15 Functional Programming Languages.
The College of Saint Rose CIS 433 – Programming Languages David Goldschmidt, Ph.D. from Concepts of Programming Languages, 9th edition by Robert W. Sebesta,
ISBN Chapter 15 Functional Programming Languages.
ISBN Chapter 15 Functional Programming Languages.
ISBN Chapter 15 Functional Programming Languages.
1 Chapter 15 © 2002 by Addison Wesley Longman, Inc Introduction - The design of the imperative languages is based directly on the von Neumann architecture.
ISBN Chapter 15 Functional Programming Languages.
TIVDM2Functional Programming Language Concepts 1 Concepts from Functional Programming Languages Peter Gorm Larsen.
8-1 Compilers Compiler A program that translates a high-level language program into machine code High-level languages provide a richer set of instructions.
CS 331 Lisp/Scheme 1 Lisp/Scheme Ruth Rutter Functional and Logic Programming Team P-Phunck.
1-1 An Introduction to Functional Programming Sept
Artificial Intelligence CIS 342 The College of Saint Rose David Goldschmidt, Ph.D.
1 Scheme (Section 11.2) CSCI 431 Programming Languages Fall 2003.
1 FP Foundations, Scheme In Text: Chapter Chapter 14: FP Foundations, Scheme Mathematical Functions Def: A mathematical function is a mapping of.
Functional Programming Part 1. Organization of Programming Languages-Cheng Big Picture u What we’ve learned so far: Imperative Programming Languages 
ISBN Chapter 15 Functional Programming Languages.
Comparative Programming Languages Functional programming with Lisp/Scheme.
ISBN Chapter 15 Functional Programming Languages.
The College of Saint Rose CIS 433 – Programming Languages David Goldschmidt, Ph.D. from Concepts of Programming Languages, 9th edition by Robert W. Sebesta,
Functional Programming
Functional Programming
Functional Programming Languages
Functional Programming Languages
Functional Programming
History of Computing – Lisp
PROGRAMMING LANGUAGES
CS 326 Programming Languages, Concepts and Implementation
Functional Programming
Functional Programming Languages
Fundamentals of Functional Programming Languages
Chapter 15 Functional Programming Languages
FP Foundations, Scheme In Text: Chapter 14.
Functional Programming Languages
Functional Programming Languages
CSE S. Tanimoto Lambda Calculus
15.2 Mathematical Functions
Chapter 15 Functional Programming 6/1/2019.
Functional Programming Languages
Presentation transcript:

The College of Saint Rose CIS 433 – Programming Languages David Goldschmidt, Ph.D. from Concepts of Programming Languages, 9th edition by Robert W. Sebesta, Addison-Wesley, 2010, ISBN

 Imperative Languages  Data and programs are both stored in memory  Variables mimic memory  Assignment statements  Arithmetic operations  Iterative repetition  Control structures  etc.

 The design of imperative languages is based directly on the von Neumann architecture  Efficiency is a primary concern  Variables are abstractions of memory locations  The design of functional languages is based directly on mathematical functions  A solid theoretical basis more natural to users  Minimally concerned with machine architecture

 A mathematical function is a mapping of members from one set (the domain) to members of another set (the range)  Parameters represent any member of the domain  Once set, a parameter is fixed to represent exactly one value during the evaluation of the mapping expression # Python def cube( x ): return x * x * x

 Mathematical functions define values whereas typical programming language functions produce values cube(x) ≡ x * x * x, where x is a real number function name function parameter(s) “is defined as” mapping expression

 A lambda expression specifies the parameters and mapping expression of a function  Essentially a nameless function  During evaluation, parameter x is bound to a particular member of the domain (x)x * x * x function parameter(s) # Python lambda x:x*x*x mapping expression

 The lambda expression is the function itself  Apply the expression to one or more parameters ( (x)x * x * x)(4) # Python (lambda x:x*x*x)(4) ( (x,y)x * y)(8,7) # Python (lambda x,y:x*y)(8,7)

 A functional form is a higher-order function that either takes functions as parameters or yields functions as its results (or both)  Example: the apply-to-all (α) functional form cube(x) ≡ x * x * x, where x is a real number α( cube, (3, 5, 2) ) ===> (27, 125, 8) # Python map( cube, [3, 5, 2] ) map( math.sqrt, [2, 3, 4, 5] ) map( lambda x,y:x+y, [3, 4, 5], [6, 7, 8] )

 In imperative languages, operations are performed and results are stored in variables for later use  Management of variables is a constant concern and source of complexity (and bugs!)  Functions in imperative language have side effects

 Functional programming languages mimic mathematical functions and mappings to the extent possible  The basic process of computation is fundamentally different than in imperative languages  No flow of control  No variables

 Write a program to calculate n-factorial  The input argument n is your only variable factorial(n) ≡ 1 if n = 0 n x factorial(n – 1) if n > 0 {

 LISP is a functional language designed at MIT by John McCarthy in 1958  Research in artificial intelligence required a language to: ▪ Process data in dynamic lists ▪ Support symbolic computation (rather than numeric)

 LISP has two data structures:  Atom: either a symbol or a numeric literal  List: a sequence of atoms and/or lists (A B C D) (A (B C) D (E (F G))) NIL

 Scheme was developed at MIT in the 1970s to be a cleaner and simpler version of LISP  Scheme uses an interpreter and built-in IDE  Literals evaluate to themselves  Scheme is available as Racket at

 Read and study Chapter 15  Download Racket  Do Exercises at the end of Chapter 15