Functional Languages  A function is an “association of a certain object from one set (the range) with each object from another set (the domain)  A function.

Slides:



Advertisements
Similar presentations
Lisp. Versions of LISP Lisp is an old language with many variants Lisp is alive and well today Most modern versions are based on Common Lisp LispWorks.
Advertisements

C-LISP. LISP 2 Lisp was invented by John McCarthy in 1958 while he was at the Massachusetts Institute of Technology (MIT).John McCarthyMassachusetts Institute.
1 Copyright © 1998 by Addison Wesley Longman, Inc. Chapter 14 Functional Programming Languages - The design of the imperative languages is based directly.
1 Scheme and Functional Programming Aaron Bloomfield CS 415 Fall 2005.
Scheme in Scheme. Why implement Scheme in Scheme  Implementing a language is a good way to learn more about programming languages  Interpreters are.
CSE 3341/655; Part 4 55 A functional program: Collection of functions A function just computes and returns a value No side-effects In fact: No program.
1 Programming Languages (CS 550) Lecture Summary Functional Programming and Operational Semantics for Scheme Jeremy R. Johnson.
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.
1-1 An Introduction to Scheme March Introduction A mid-1970s dialect of LISP, designed to be a cleaner, more modern, and simpler version than.
Scheme for Python Programmers CSE Valeria Montero.
CS 330 Programming Languages 11 / 20 / 2007 Instructor: Michael Eckmann.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 14 Functional Programming It is better to.
ISBN Chapter 15 Functional Programming Languages Mathematical Functions Fundamentals of Functional Programming Languages Introduction to.
Introductory Lisp Programming Lecture # 2 Main Topics –Basic Lisp data types –Lisp primitives –Details of list handling Cons cells (boxes) & their representation.
Spring 2008Programming Development Techniques 1 Topic 6 Hierarchical Data and the Closure Property Section September 2008.
Lisp by Namtap Tapchareon Lisp Background  Lisp was developed by John McCarthy in  Lisp is derives from List Processing Language. 
(5.1) COEN Functional Languages  Functional programming basics  Atoms and lists; cons  Useful primitive functions  Predicates  Arithmetic functions.
LISP 1.5 and beyond A very quick tour. Data Atoms (symbols) including numbers – All types of numbers including Roman! (well, in the early days) – Syntactically.
Functional Languages. Why? Referential Transparency Functions as first class objects Higher level of abstraction Potential for parallel execution.
Functional Programming in Scheme
CSC3315 (Spring 2009)1 CSC 3315 Programming Paradigms Scheme Language Hamid Harroud School of Science and Engineering, Akhawayn University
ISBN Chapter 15 Functional Programming Languages.
Λ => Scheme for Rubyists. Scheme History Authors: Guy Steele and Gerald Sussman Structure and Interpretation of Computer Programs (SICP) by Abelson &
Introduction to Scheme CS 480/680 – Comparative Languages “And now for something completely different…” – Monty Python “And now for something completely.
14-October-2002cse Lists © 2002 University of Washington1 Lists CSE 413, Autumn 2002 Programming Languages
Lisp Functional Language or Applicative Language –Achieves its effect by applying functions, either recursively or through composition Powerful, expressive,
ISBN Chapter 15 Functional Programming Languages.
CS535 Programming Languages Chapter - 10 Functional Programming With Lists.
UMBC CMSC Common Lisp II. UMBC CMSC Input and Output Print is the most primitive output function > (print (list 'foo 'bar)) (FOO BAR) The.
Scheme Profs Tim Sheard and Andrew Black CS 311 Computational Structures.
Milos Hauskrecht (PDF) Hieu D. Vu (PPT) LISP PROGARMMING LANGUAGE.
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 
Functional Programming. Some Functional Languages Lisp Scheme - a dialect of Lisp Haskell Miranda.
CSE 425: Functional Programming I Programs as Functions Some programs act like mathematical functions –Associate a set of input values from the function’s.
C H A P T E R E I G H T Functional Programming Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
CS 152: Programming Language Paradigms February 12 Class Meeting Department of Computer Science San Jose State University Spring 2014 Instructor: Ron Mak.
LISP LISt Processing. History & Overview b b One of the oldest high level programming languages. b b First developed in 1958 by John McCarthy. b b Later.
Functional Programming
Functional Programming Languages
Functional Programming Languages
Functional Programming
History of Computing – Lisp
CS 3304 Comparative Languages
CS 326 Programming Languages, Concepts and Implementation
A I (Artificial Intelligence)
CS 326 Programming Languages, Concepts and Implementation
Chapter 15 – Functional Programming Languages
September 4, 1997 Programming Languages (CS 550) Lecture 6 Summary Operational Semantics of Scheme using Substitution Jeremy R. Johnson TexPoint fonts.
Lists in Lisp and Scheme
LISP LISt Processing.
PZ10CX - LISP Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section Appendix A.6.
Lecture 6: Programming with Data CS150: Computer Science
FP Foundations, Scheme In Text: Chapter 14.
CSE 3302 Programming Languages
Defining Functions with DEFUN
LISP LISt Processing.
Abstraction and Repetition
LISP LISt Processing.
COP4020 Programming Languages
Modern Programming Languages Lecture 18 Fakhar Lodhi
topics interpreters meta-linguistic abstraction eval and apply
Common Lisp II.
Lesson 5.3 What is a Function?
Chapter 15 Functional Programming 6/1/2019.
Programming Languages
Lisp.
LISP primitives on sequences
Presentation transcript:

Functional Languages  A function is an “association of a certain object from one set (the range) with each object from another set (the domain)  A function is an expression and its associated values, where the expression provides a method or rule for making the association between domain and range values.

Functional languages  Ways of expressing functions –Age(Amalia) = 7 –(Age Amalia) –(age Amalia 7)  function / applicative  Functions are single valued – for each domain value there is exactly one associated range value.

Functional Languages  Distinguishing Features –Programs are a composition of functions –Functions are supported as first-class objects Functions can be arguments to other functions –There are relatively few side effects –Simple semantics –Recursive control prevalent

Functional Languages  LISP –Typeless –Primary data structure is the list  Scheme – a dialog of LISP –typeless  ML = Meta Language –Strongly typed  APL – not purely functional –Primary data structure is the array  FP

Relations vs Functions  Relation is –Ordered association of elements of ten listed as a tuple  Function –Given an ordered tuple (argument list of elements) returns a value  Composition of functions example (+ (* w x) ( - y z))

First Order Functions  A function is first-order if it takes individuals as arguments and returns an individual value –Numbers –Strings –Records –Etc.  An individual is a function of order 0

Side Effects  A function (f x y z) is said to have a side effect if x,y, and/or z change in the calling environment during application of the function. –GetData (x,y,z) –(GetData Getx Gety Getz)  A function defined with all value parameters, and where no assignments are made to global variables, has no side effects.

Clean Semantics  Language means what it says  Language is not ambiguous  Results of a program can be verified

LISP – a functional language  History –First major AI workshop summer 1956 – at Dartmouth –John McCarthy – late 50’s – MIT Kleene’s - recursive function theory Alonzo Church’s – lambda calculus –IBM 704 few primitives Punched cards –Good for AI areas of Robotics & knowledge engineering –Standardization attempt: Common LISP

Knowledge Engineering  Expert Systems –Public knowledge Textbooks –Private knowledge Heuristics (rules of thumb) –Examples DENDRAL – data analysis MACYSYMA – symbolic calculus EXPERT – medical MYCIN – infectious disease diagnosis & prescription

LISP – a functional language  McCarthy’s original LISP – 6 functions cons, cond, car, cdr, eq, atom  Today’s LISP – many more functions –Arithmetic –Input –Output

LISP – a functional language  Simple Data Type –Atom Number –Use built in hardware for integer & real arithmetic String  Structured Data Type –List Cam be empty () Can contain an ordered list

LISP – a functional language  LISP manages pointers for you –ordinary Lisp lists are singly linked lists  When dealing with recursion –Need a base case (stopping case) –Need a recursive case  Common Lisp provides macros for push and pop (xlisp doesn’t)

LISP – a functional language  (setf pair (cons ‘a ‘b)) –returns the dotted pair (A.B) –(A.B) is a two part data structure –A is the car of the cons –B is the cdr of the cons