Functional Programming

Size: px
Start display at page:

Download "Functional Programming"

Transcription

1 The Meta Language (ML) and Functional Programming Daniel S. Fava Department of informatics University of Oslo, Norway

2 Motivation ML Demo

3 Which programming languages are functional?

4 Which programming languages are functional? Lambda calculus 1930 (a model of computation)

5 Which programming languages are functional? Lambda calculus 1930 (a model of computation) Lisp 1950 ML 1973

6 Which programming languages are functional? Lambda calculus 1930 (a model of computation) Lisp 1950 dynamically typed ML 1973 statically typed

7 Which programming languages are functional? Lambda calculus 1930 (a model of computation) Lisp 1950 dynamically typed Scheme 1970 Racket 1995 ML 1973 statically typed

8 Which programming languages are functional? Lambda calculus 1930 (a model of computation) Lisp 1950 dynamically typed Scheme 1970 Racket 1995 ML 1973 statically typed Standard ML or SML Caml 1985 OCaml 1996

9 Which programming languages are functional? Lambda calculus 1930 (a model of computation) Lisp 1950 dynamically typed Scheme 1970 Racket 1995 ML 1973 statically typed Standard ML or SML Caml 1985 OCaml 1996 Haskell 1990

10 Which programming languages are functional? Lambda calculus 1930 (a model of computation) Lisp 1950 dynamically typed Scheme 1970 Racket 1995 ML 1973 statically typed Standard ML or SML Caml 1985 OCaml 1996 Haskell 1990 Erlang 1986, Scala 2004, Clojure 2007 (multi-paradigm)

11 Why another programming paradigm?

12 Why another programming paradigm? A different way of thinking

13 Why another programming paradigm? A different way of thinking Non-functional PLs borrowing functional constructs

14 Why another programming paradigm? A different way of thinking Non-functional PLs borrowing functional constructs JavaScript, Python, Lua, PHP, C++11, C#...

15 Why another programming paradigm? A different way of thinking Non-functional PLs borrowing functional constructs JavaScript, Python, Lua, PHP, C++11, C#... MapReduce

16 Why another programming paradigm? A different way of thinking Non-functional PLs borrowing functional constructs JavaScript, Python, Lua, PHP, C++11, C#... MapReduce Debatable

17 Why another programming paradigm? A different way of thinking Non-functional PLs borrowing functional constructs JavaScript, Python, Lua, PHP, C++11, C#... MapReduce Debatable easier to reason about and to prove properties of

18 Why another programming paradigm? A different way of thinking Non-functional PLs borrowing functional constructs JavaScript, Python, Lua, PHP, C++11, C#... MapReduce Debatable easier to reason about and to prove properties of more compact, simpler code

19 Why another programming paradigm? A different way of thinking Non-functional PLs borrowing functional constructs JavaScript, Python, Lua, PHP, C++11, C#... MapReduce Debatable easier to reason about and to prove properties of in the eye of the beholder more compact, simpler code

20 Why another programming paradigm? A different way of thinking Non-functional PLs borrowing functional constructs JavaScript, Python, Lua, PHP, C++11, C#... MapReduce Debatable easier to reason about and to prove properties of in the eye of the beholder more compact, simpler code problems can be easier to express given certain idioms match the language to the problem

21 What is functional programming? [100]a [100]a [100]a [100]a

22 What is functional programming? It is programming with: [100]a [100]a [100]a [100]a

23 What is functional programming? It is programming with: first-class and higher-order functions [100]a [100]a [100]a

24 What is functional programming? It is programming with: first-class and higher-order functions purity [100]a [100]a

25 What is functional programming? It is programming with: first-class and higher-order functions purity pattern matching [100]a

26 What is functional programming? It is programming with: first-class and higher-order functions purity pattern matching recursion

27 first-class and higher-order functions purity pattern matching recursion

28 first-class and higher-order functions Currying Closures purity pattern matching recursion

29 first-class and higher-order functions Currying Closures purity Statements versus Expressions and Declarations Side effects versus Effect free Immutability Referential transparency pattern matching recursion

30 first-class and higher-order functions Currying Closures purity Statements versus Expressions and Declarations Side effects versus Effect free Immutability Referential transparency pattern matching constructors and pattern matching data structures Nat, Lists, Trees, etc recursion

31 first-class and higher-order functions Currying Closures purity Statements versus Expressions and Declarations Side effects versus Effect free Immutability Referential transparency pattern matching constructors and pattern matching data structures Nat, Lists, Trees, etc recursion tail recursion termination and total functions continuations and continuation passing style (CPS)

32 The Meta Language (ML) ML is a functional programming language with imperative features,

33 The Meta Language (ML) ML is a functional programming language with imperative features, it was part of project to create an interactive theorem prover.

34 The Meta Language (ML) ML is a functional programming language with imperative features, it was part of project to create an interactive theorem prover. Logic for Computable Functions (LCF)

35 The Meta Language (ML) ML is a functional programming language with imperative features, it was part of project to create an interactive theorem prover. Logic for Computable Functions (LCF) Project headed by Robin Milner in 1972.

36 The Meta Language (ML) ML is a functional programming language with imperative features, it was part of project to create an interactive theorem prover. Logic for Computable Functions (LCF) Project headed by Robin Milner in notation for programs

37 The Meta Language (ML) ML is a functional programming language with imperative features, it was part of project to create an interactive theorem prover. Logic for Computable Functions (LCF) Project headed by Robin Milner in notation for programs notation for proofs (eg. proof that quicksort returns a sorted array)

38 The Meta Language (ML) ML is a functional programming language with imperative features, it was part of project to create an interactive theorem prover. Logic for Computable Functions (LCF) Project headed by Robin Milner in notation for programs notation for proofs (eg. proof that quicksort returns a sorted array) write programs that search for proofs

39 The Meta Language (ML) ML is a functional programming language with imperative features, it was part of project to create an interactive theorem prover. Logic for Computable Functions (LCF) Project headed by Robin Milner in notation for programs notation for proofs (eg. proof that quicksort returns a sorted array) write programs that search for proofs have a program that checks a proof

40 tactic : formula proof

41 Composition of tactics tactic : formula proof

42 tactic : formula proof Composition of tactics Take tactics as input and return a more complex tactic

43 tactic : formula proof Composition of tactics Take tactics as input and return a more complex tactic Proof checking

44 tactic : formula proof Composition of tactics Take tactics as input and return a more complex tactic Proof checking theorem abstract data type

45 tactic : formula proof Composition of tactics Take tactics as input and return a more complex tactic Proof checking theorem abstract data type theorems derivable only via inference rules given by theorem

46 tactic : formula proof Composition of tactics Take tactics as input and return a more complex tactic Proof checking theorem abstract data type theorems derivable only via inference rules given by theorem calling tactic on a formula can either:

47 tactic : formula proof Composition of tactics Take tactics as input and return a more complex tactic Proof checking theorem abstract data type theorems derivable only via inference rules given by theorem calling tactic on a formula can either: terminate and return a proof, or

48 tactic : formula proof Composition of tactics Take tactics as input and return a more complex tactic Proof checking theorem abstract data type theorems derivable only via inference rules given by theorem calling tactic on a formula can either: terminate and return a proof, or diverge, which means run forever, or

49 tactic : formula proof Composition of tactics Take tactics as input and return a more complex tactic Proof checking theorem abstract data type theorems derivable only via inference rules given by theorem calling tactic on a formula can either: terminate and return a proof, or diverge, which means run forever, or raise an exception

50 tactic : formula proof Composition of tactics Higher-order functions Take tactics as input and return a more complex tactic Proof checking theorem abstract data type theorems derivable only via inference rules given by theorem calling tactic on a formula can either: terminate and return a proof, or diverge, which means run forever, or raise an exception

51 tactic : formula proof Composition of tactics Higher-order functions Take tactics as input and return a more complex tactic Proof checking theorem abstract data type Expressive and sound type system theorems derivable only via inference rules given by theorem calling tactic on a formula can either: terminate and return a proof, or diverge, which means run forever, or raise an exception

52 tactic : formula proof Composition of tactics Higher-order functions Take tactics as input and return a more complex tactic Proof checking theorem abstract data type Expressive and sound type system theorems derivable only via inference rules given by theorem calling tactic on a formula can either: terminate and return a proof, or diverge, which means run forever, or raise an exception First language with type-safe exceptions

53 Read-Evaluate-Print Loop (REPL)

54 Read-Evaluate-Print Loop (REPL) In ML, expressions are type-checked after R and before E

CMSC 330: Organization of Programming Languages. Functional Programming with OCaml

CMSC 330: Organization of Programming Languages. Functional Programming with OCaml CMSC 330: Organization of Programming Languages Functional Programming with OCaml 1 What is a functional language? A functional language: defines computations as mathematical functions discourages use

More information

COS 326 Functional programming: an elegant weapon for the modern age

COS 326 Functional programming: an elegant weapon for the modern age COS 326 Functional programming: an elegant weapon for the modern age In 1936, Alonzo Church invented the lambda calculus. He called it a logic, but it was a language of pure functions -- the world's first

More information

Functional Programming Lecture 13: FP in the Real World

Functional Programming Lecture 13: FP in the Real World Functional Programming Lecture 13: FP in the Real World Viliam Lisý Artificial Intelligence Center Department of Computer Science FEE, Czech Technical University in Prague viliam.lisy@fel.cvut.cz 1 Mixed

More information

CSCI-GA Scripting Languages

CSCI-GA Scripting Languages CSCI-GA.3033.003 Scripting Languages 12/02/2013 OCaml 1 Acknowledgement The material on these slides is based on notes provided by Dexter Kozen. 2 About OCaml A functional programming language All computation

More information

Introduction to OCaml

Introduction to OCaml Fall 2018 Introduction to OCaml Yu Zhang Course web site: http://staff.ustc.edu.cn/~yuzhang/tpl References Learn X in Y Minutes Ocaml Real World OCaml Cornell CS 3110 Spring 2018 Data Structures and Functional

More information

Refactoring to Functional. Hadi Hariri

Refactoring to Functional. Hadi Hariri Refactoring to Functional Hadi Hariri Functional Programming In computer science, functional programming is a programming paradigm, a style of building the structure and elements of computer programs,

More information

ITT8060 Advanced Programming

ITT8060 Advanced Programming ITT8060 Advanced Programming In F# Juhan Ernits Welcome to Advanced Programming (in F#)! Teachers: Juhan Ernits Hendrik Maarand Course web page http://courses.cs.ttu.ee/pages/itt8060 Contact: juhan.ernits@ttu.ee

More information

Scope and Introduction to Functional Languages. Review and Finish Scoping. Announcements. Assignment 3 due Thu at 11:55pm. Website has SML resources

Scope and Introduction to Functional Languages. Review and Finish Scoping. Announcements. Assignment 3 due Thu at 11:55pm. Website has SML resources Scope and Introduction to Functional Languages Prof. Evan Chang Meeting 7, CSCI 3155, Fall 2009 Announcements Assignment 3 due Thu at 11:55pm Submit in pairs Website has SML resources Text: Harper, Programming

More information

CSE341: Programming Languages Interlude: Course Motivation. Zach Tatlock Winter 2018

CSE341: Programming Languages Interlude: Course Motivation. Zach Tatlock Winter 2018 CSE341: Programming Languages Interlude: Course Motivation Zach Tatlock Winter 2018 Course Motivation (Did you think I forgot? J) Why learn the fundamental concepts that appear in all (most?) languages?

More information

Concepts of Programming Languages

Concepts of Programming Languages Concepts of Programming Languages Lecture 15 - Functional Programming Patrick Donnelly Montana State University Spring 2014 Patrick Donnelly (Montana State University) Concepts of Programming Languages

More information

Functional Programming Lecture 1: Introduction

Functional Programming Lecture 1: Introduction Functional Programming Lecture 1: Introduction Viliam Lisý Artificial Intelligence Center Department of Computer Science FEE, Czech Technical University in Prague viliam.lisy@fel.cvut.cz Acknowledgements

More information

Introduction to ML. Based on materials by Vitaly Shmatikov. General-purpose, non-c-like, non-oo language. Related languages: Haskell, Ocaml, F#,

Introduction to ML. Based on materials by Vitaly Shmatikov. General-purpose, non-c-like, non-oo language. Related languages: Haskell, Ocaml, F#, Introduction to ML Based on materials by Vitaly Shmatikov slide 1 ML General-purpose, non-c-like, non-oo language Related languages: Haskell, Ocaml, F#, Combination of Lisp and Algol-like features (1958)

More information

Introduction to Functional Programming and Haskell. Aden Seaman

Introduction to Functional Programming and Haskell. Aden Seaman Introduction to Functional Programming and Haskell Aden Seaman Functional Programming Functional Programming First Class Functions Expressions (No Assignment) (Ideally) No Side Effects Different Approach

More information

Quick announcement. Midterm date is Wednesday Oct 24, 11-12pm.

Quick announcement. Midterm date is Wednesday Oct 24, 11-12pm. Quick announcement Midterm date is Wednesday Oct 24, 11-12pm. The lambda calculus = ID (λ ID. ) ( ) The lambda calculus (Racket) = ID (lambda (ID) ) ( )

More information

h0ps://

h0ps:// 2 For more insanity: h0ps://www.destroyallso7ware.com/talks/wat [Broader point: No one (few people) knows what their programs do in untyped languages.] 3 Type Checking Basics COS 326 David Walker Princeton

More information

COS 326 Func,onal Programming: An elegant weapon for the modern age David Walker Princeton University

COS 326 Func,onal Programming: An elegant weapon for the modern age David Walker Princeton University 2007 xkcd COS 326 Func,onal Programming: An elegant weapon for the modern age David Walker Princeton University slides copyright 2013-2015 David Walker and Andrew W. Appel permission granted to reuse these

More information

Functional Programming. Big Picture. Design of Programming Languages

Functional Programming. Big Picture. Design of Programming Languages Functional Programming Big Picture What we ve learned so far: Imperative Programming Languages Variables, binding, scoping, reference environment, etc What s next: Functional Programming Languages Semantics

More information

Closures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming

Closures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming Closures Mooly Sagiv Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming Summary 1. Predictive Parsing 2. Large Step Operational Semantics (Natural) 3. Small Step Operational Semantics

More information

Functional Programming Principles in Scala. Martin Odersky

Functional Programming Principles in Scala. Martin Odersky Functional Programming Principles in Scala Martin Odersky Programming Paradigms Paradigm: In science, a paradigm describes distinct concepts or thought patterns in some scientific discipline. Main programming

More information

Introduction to SML Getting Started

Introduction to SML Getting Started Introduction to SML Getting Started Michael R. Hansen mrh@imm.dtu.dk Informatics and Mathematical Modelling Technical University of Denmark c Michael R. Hansen, Fall 2004 p.1/15 Background Standard Meta

More information

A Practical Optional Type System for Clojure. Ambrose Bonnaire-Sergeant

A Practical Optional Type System for Clojure. Ambrose Bonnaire-Sergeant A Practical Optional Type System for Clojure Ambrose Bonnaire-Sergeant Statically typed vs. Dynamically typed Traditional distinction Dynamically typed Statically typed eg. Java, C, Haskell eg. Javascript,

More information

The design of a programming language for provably correct programs: success and failure

The design of a programming language for provably correct programs: success and failure The design of a programming language for provably correct programs: success and failure Don Sannella Laboratory for Foundations of Computer Science School of Informatics, University of Edinburgh http://homepages.inf.ed.ac.uk/dts

More information

CSCI 2041: Introduction

CSCI 2041: Introduction CSCI 2041: Introduction Chris Kauffman Last Updated: Wed Sep 5 11:56:55 CDT 2018 1 Logistics Reading OCaml System Manual: 1.1-1.3 Practical OCaml: Ch 1-2 Goals History Tour of OCaml Language First Programs

More information

Introduction. chapter Functions

Introduction. chapter Functions chapter 1 Introduction In this chapter we set the stage for the rest of the book. We start by reviewing the notion of a function, then introduce the concept of functional programming, summarise the main

More information

Robot Programming with Lisp

Robot Programming with Lisp 4. Functional Programming: Higher-order Functions, Map/Reduce, Lexical Scope Institute for Artificial University of Bremen 9 of November, 2017 Functional Programming Pure functional programming concepts

More information

Introduction to ML. Mooly Sagiv. Cornell CS 3110 Data Structures and Functional Programming

Introduction to ML. Mooly Sagiv. Cornell CS 3110 Data Structures and Functional Programming Introduction to ML Mooly Sagiv Cornell CS 3110 Data Structures and Functional Programming The ML Programming Language General purpose programming language designed by Robin Milner in 1970 Meta Language

More information

Stop coding Pascal. Saturday, April 6, 13

Stop coding Pascal. Saturday, April 6, 13 Stop coding Pascal...emotional sketch about past, present and future of programming languages, Python, compilers, developers, Life, Universe and Everything Alexey Kachayev CTO at KitApps Inc. Open source

More information

Simply-Typed Lambda Calculus

Simply-Typed Lambda Calculus #1 Simply-Typed Lambda Calculus #2 Back to School What is operational semantics? When would you use contextual (small-step) semantics? What is denotational semantics? What is axiomatic semantics? What

More information

Lecture 8: Summary of Haskell course + Type Level Programming

Lecture 8: Summary of Haskell course + Type Level Programming Lecture 8: Summary of Haskell course + Type Level Programming Søren Haagerup Department of Mathematics and Computer Science University of Southern Denmark, Odense October 31, 2017 Principles from Haskell

More information

Introduction to ML. Mooly Sagiv. Cornell CS 3110 Data Structures and Functional Programming

Introduction to ML. Mooly Sagiv. Cornell CS 3110 Data Structures and Functional Programming Introduction to ML Mooly Sagiv Cornell CS 3110 Data Structures and Functional Programming The ML Programming Language General purpose programming language designed by Robin Milner in 1970 Meta Language

More information

15. Functional Programming

15. Functional Programming 15. Functional Programming 15.1 Introduction The design of the imperative languages is based directly on the von Neumann architecture Efficiency is the primary concern, rather than the suitability of the

More information

Functional Programming and Haskell

Functional Programming and Haskell Functional Programming and Haskell Tim Dawborn University of Sydney, Australia School of Information Technologies Tim Dawborn Functional Programming and Haskell 1/22 What are Programming Paradigms? A programming

More information

CSE 341: Programming Languages

CSE 341: Programming Languages CSE 341: Programming Languages Dan Grossman Spring 2008 Lecture 6 Nested pattern-matching; course motivation Dan Grossman CSE341 Spring 2008, Lecture 6 1 Patterns What we know: case-expresssions do pattern-matching

More information

CS 11 Haskell track: lecture 1

CS 11 Haskell track: lecture 1 CS 11 Haskell track: lecture 1 This week: Introduction/motivation/pep talk Basics of Haskell Prerequisite Knowledge of basic functional programming e.g. Scheme, Ocaml, Erlang CS 1, CS 4 "permission of

More information

SD314 Outils pour le Big Data

SD314 Outils pour le Big Data Institut Supérieur de l Aéronautique et de l Espace SD314 Outils pour le Big Data Functional programming in Python Christophe Garion DISC ISAE Christophe Garion SD314 Outils pour le Big Data 1/ 35 License

More information

PL Categories: Functional PLs Introduction to Haskell Haskell: Functions

PL Categories: Functional PLs Introduction to Haskell Haskell: Functions PL Categories: Functional PLs Introduction to Haskell Haskell: Functions CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Wednesday, February 22, 2017 Glenn G. Chappell

More information

CIS24 Project #3. Student Name: Chun Chung Cheung Course Section: SA Date: 4/28/2003 Professor: Kopec. Subject: Functional Programming Language (ML)

CIS24 Project #3. Student Name: Chun Chung Cheung Course Section: SA Date: 4/28/2003 Professor: Kopec. Subject: Functional Programming Language (ML) CIS24 Project #3 Student Name: Chun Chung Cheung Course Section: SA Date: 4/28/2003 Professor: Kopec Subject: Functional Programming Language (ML) 1 Introduction ML Programming Language Functional programming

More information

Introduction to ML. Mooly Sagiv. Cornell CS 3110 Data Structures and Functional Programming

Introduction to ML. Mooly Sagiv. Cornell CS 3110 Data Structures and Functional Programming Introduction to ML Mooly Sagiv Cornell CS 3110 Data Structures and Functional Programming Typed Lambda Calculus Chapter 9 Benjamin Pierce Types and Programming Languages Call-by-value Operational Semantics

More information

FUNCTIONAL PROGRAMMING

FUNCTIONAL PROGRAMMING FUNCTIONAL PROGRAMMING Map, Fold, and MapReduce Prof. Clarkson Summer 2015 Today s music: Selections from the soundtrack to 2001: A Space Odyssey Review Yesterday: Lists: OCaml's awesome built-in datatype

More information

Welcome to. Instructor Marc Pomplun CS 470/670. Introduction to Artificial Intelligence 1/26/2016. Spring Selectivity in Complex Scenes

Welcome to. Instructor Marc Pomplun CS 470/670. Introduction to Artificial Intelligence 1/26/2016. Spring Selectivity in Complex Scenes Welcome to CS 470/670 Introduction to Artificial Intelligence Office: Lab: Instructor Marc Pomplun S-3-171 S-3-135 Office Hours: Tuesdays 4:00pm 5:30pm Thursdays 7:00pm 8:30pm Spring 2016 Instructor: Marc

More information

Functional Programming

Functional Programming Functional Programming Björn B. Brandenburg The University of North Carolina at Chapel Hill Based in part on slides and notes by S. Olivier, A. Block, N. Fisher, F. Hernandez-Campos, and D. Stotts. Brief

More information

Language Sequence. The Algol Family and ML. Algol 60 Sample. Algol 60. Some trouble spots in Algol 60. Algol Joke. John Mitchell

Language Sequence. The Algol Family and ML. Algol 60 Sample. Algol 60. Some trouble spots in Algol 60. Algol Joke. John Mitchell CS 4 Language Sequence The Algol Family and ML Lisp Algol 60 John Mitchell Algol 68 Pascal ML Modula Reading: Chapter 5 Many other languages: Algol 58, Algol W, Euclid, EL, Mesa (PARC), Modula-, Oberon,

More information

Topic I. Introduction and motivation References: Chapter 1 of Concepts in programming languages by J. C. Mitchell. CUP, 2003.

Topic I. Introduction and motivation References: Chapter 1 of Concepts in programming languages by J. C. Mitchell. CUP, 2003. Topic I Introduction and motivation References: Chapter 1 of Concepts in programming languages by J. C. Mitchell. CUP, 2003. Chapter 1 of Programming languages: Design and implementation (3RD EDITION)

More information

Announcements. CSCI 334: Principles of Programming Languages. Lecture 5: Fundamentals III & ML

Announcements. CSCI 334: Principles of Programming Languages. Lecture 5: Fundamentals III & ML Announcements CSCI 334: Principles of Programming Languages Lecture 5: Fundamentals III & ML Instructor: Dan Barowy Claire Booth Luce info session tonight for women interested in summer research (hopefully

More information

CSCE 314 TAMU Fall CSCE 314: Programming Languages Dr. Flemming Andersen. Haskell Basics

CSCE 314 TAMU Fall CSCE 314: Programming Languages Dr. Flemming Andersen. Haskell Basics 1 CSCE 314: Programming Languages Dr. Flemming Andersen Haskell Basics 2 Contents 1. Jump into Haskell: Using ghc and ghci (more detail) 2. Historical Background of Haskell 3. Lazy, Pure, and Functional

More information

CPL 2016, week 10. Clojure functional core. Oleg Batrashev. April 11, Institute of Computer Science, Tartu, Estonia

CPL 2016, week 10. Clojure functional core. Oleg Batrashev. April 11, Institute of Computer Science, Tartu, Estonia CPL 2016, week 10 Clojure functional core Oleg Batrashev Institute of Computer Science, Tartu, Estonia April 11, 2016 Overview Today Clojure language core Next weeks Immutable data structures Clojure simple

More information

Swift, functional programming, and does it matter? Alexis

Swift, functional programming, and does it matter? Alexis Swift, functional programming, and does it matter? Alexis Gallagher @alexisgallagher Questions What s new in Swift? Is Swift a functional programming language? And what is functional anyway? How useful

More information

Com S 541. Programming Languages I

Com S 541. Programming Languages I Programming Languages I Lecturer: TA: Markus Lumpe Department of Computer Science 113 Atanasoff Hall http://www.cs.iastate.edu/~lumpe/coms541.html TR 12:40-2, W 5 Pramod Bhanu Rama Rao Office hours: TR

More information

Software System Design and Implementation

Software System Design and Implementation Software System Design and Implementation Functional Programming Gabriele Keller The University of New South Wales School of Computer Science and Engineering Sydney, Australia COMP3141 16s1 Course software

More information

Introduction to Functional Programming

Introduction to Functional Programming Introduction to Functional Programming Xiao Jia xjia@cs.sjtu.edu.cn Summer 2013 Scheme Appeared in 1975 Designed by Guy L. Steele Gerald Jay Sussman Influenced by Lisp, ALGOL Influenced Common Lisp, Haskell,

More information

Functional programming in C#

Functional programming in C# Functional programming in C# A quick approach to another paradigm Nacho Iborra IES San Vicente This work is licensed under the Creative Commons Attribution- NonCommercial-ShareAlike 4.0 International License.

More information

A Func'onal Introduc'on. COS 326 David Walker Princeton University

A Func'onal Introduc'on. COS 326 David Walker Princeton University A Func'onal Introduc'on COS 326 David Walker Princeton University Thinking Func'onally In Java or C, you get (most) work done by changing something temp = pair.x; pair.x = pair.y; pair.y = temp; commands

More information

IA010: Principles of Programming Languages

IA010: Principles of Programming Languages IA010: Principles of Programming Languages Introduction and course organization Achim Blumensath blumens@fi.muni.cz Faculty of Informatics, Masaryk University, Brno Warm-up: A Quiz What does this program

More information

Introduction to Functional Programming in Haskell 1 / 56

Introduction to Functional Programming in Haskell 1 / 56 Introduction to Functional Programming in Haskell 1 / 56 Outline Why learn functional programming? The essence of functional programming What is a function? Equational reasoning First-order vs. higher-order

More information

Programs and Proofs in Isabelle/HOL

Programs and Proofs in Isabelle/HOL Programs and Proofs in Isabelle/HOL Makarius Wenzel http://sketis.net March 2016 = Isabelle λ β α Introduction What is Isabelle? Hanabusa Itcho : Blind monks examining an elephant Introduction 2 History:

More information

The Algol family and ML

The Algol family and ML The Algol family and ML Volker Stolz stolz@ifi.uio.no Department of Informatics University of Oslo Initially by Gerardo Schneider. Based on John C. Mitchell s slides (Stanford U.) ML lectures 16.09: The

More information

Is Functional Programming (FP) for me? ACCU Conference 2008 Hubert Matthews

Is Functional Programming (FP) for me? ACCU Conference 2008 Hubert Matthews Is Functional Programming (FP) for me? ACCU Conference 2008 Hubert Matthews hubert@oxyware.com Overview of talk History of computing Types of problem, developers, solution, environments, managers Pros

More information

INTRODUCTION TO FUNCTIONAL PROGRAMMING

INTRODUCTION TO FUNCTIONAL PROGRAMMING INTRODUCTION TO FUNCTIONAL PROGRAMMING Graham Hutton University of Nottingham adapted by Gordon Uszkay 1 What is Functional Programming? Opinions differ, and it is difficult to give a precise definition,

More information

Closures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming

Closures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming Closures Mooly Sagiv Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming t ::= x x. t t t Call-by-value big-step Operational Semantics terms variable v ::= values abstraction x.

More information

CSCI.4430/6969 Programming Languages Lecture Notes

CSCI.4430/6969 Programming Languages Lecture Notes CSCI.4430/6969 Programming Languages Lecture Notes August 28, 2006 1 Brief History of Programming Languages Ada Augusta, the Countess of Lovelace, the daughter of the poet Lord Byron, is attributed as

More information

Chapter 11 :: Functional Languages

Chapter 11 :: Functional Languages Chapter 11 :: Functional Languages Programming Language Pragmatics Michael L. Scott Copyright 2016 Elsevier 1 Chapter11_Functional_Languages_4e - Tue November 21, 2017 Historical Origins The imperative

More information

CS252 Advanced Programming Language Principles. Prof. Tom Austin San José State University Fall 2013

CS252 Advanced Programming Language Principles. Prof. Tom Austin San José State University Fall 2013 CS252 Advanced Programming Language Principles Prof. Tom Austin San José State University Fall 2013 What are some programming languages? Why are there so many? Different domains Mobile devices (Objective

More information

CS Lecture 6: Map and Fold. Prof. Clarkson Spring Today s music: Selections from the soundtrack to 2001: A Space Odyssey

CS Lecture 6: Map and Fold. Prof. Clarkson Spring Today s music: Selections from the soundtrack to 2001: A Space Odyssey CS 3110 Lecture 6: Map and Fold Prof. Clarkson Spring 2015 Today s music: Selections from the soundtrack to 2001: A Space Odyssey Review Course so far: Syntax and semantics of (most of) OCaml Today: No

More information

JVM ByteCode Interpreter

JVM ByteCode Interpreter JVM ByteCode Interpreter written in Haskell (In under 1000 Lines of Code) By Louis Jenkins Presentation Schedule ( 15 Minutes) Discuss and Run the Virtual Machine first

More information

Programming Languages

Programming Languages : Winter 2010 Principles of Programming Languages Lecture 1: Welcome, etc. Ranjit Jhala UC San Diego Computation & Interaction Precisely expressed by PL Dependence means need for analysis Safety Security

More information

Combining Programming with Theorem Proving

Combining Programming with Theorem Proving Combining Programming with Theorem Proving Chiyan Chen and Hongwei Xi Boston University Programming with Theorem Proving p.1/27 Motivation for the Research To support advanced type systems for practical

More information

Introduction to Functional Programming in Racket. CS 550 Programming Languages Jeremy Johnson

Introduction to Functional Programming in Racket. CS 550 Programming Languages Jeremy Johnson Introduction to Functional Programming in Racket CS 550 Programming Languages Jeremy Johnson 1 Objective To introduce functional programming in racket Programs are functions and their semantics involve

More information

Chapter 15. Functional Programming Languages

Chapter 15. Functional Programming Languages Chapter 15 Functional Programming Languages Chapter 15 Topics Introduction Mathematical Functions Fundamentals of Functional Programming Languages The First Functional Programming Language: Lisp Introduction

More information

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen COP4020 Programming Languages Functional Programming Prof. Robert van Engelen Overview What is functional programming? Historical origins of functional programming Functional programming today Concepts

More information

Formal Systems and their Applications

Formal Systems and their Applications Formal Systems and their Applications Dave Clarke (Dave.Clarke@cs.kuleuven.be) Acknowledgment: these slides are based in part on slides from Benjamin Pierce and Frank Piessens 1 Course Overview Introduction

More information

Recursion. Lecture 6: More Lambda Calculus Programming. Fixed Points. Recursion

Recursion. Lecture 6: More Lambda Calculus Programming. Fixed Points. Recursion Recursion Lecture 6: More Lambda Calculus Programming CSC 131! Fall, 2014!! Kim Bruce Recursive definitions are handy! - fact = λn. cond (iszero n) 1 (Mult n (fact (Pred n)))! - Not a legal definition

More information

A Brief Introduction to Standard ML

A Brief Introduction to Standard ML A Brief Introduction to Standard ML Specification and Verification with Higher-Order Logic Arnd Poetzsch-Heffter (Slides by Jens Brandt) Software Technology Group Fachbereich Informatik Technische Universität

More information

CPS 506 Comparative Programming Languages. Programming Language Paradigm

CPS 506 Comparative Programming Languages. Programming Language Paradigm CPS 506 Comparative Programming Languages Functional Programming Language Paradigm Topics Introduction Mathematical Functions Fundamentals of Functional Programming Languages The First Functional Programming

More information

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011 CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics Dan Grossman Spring 2011 Review e ::= λx. e x e e c v ::= λx. e c τ ::= int τ τ Γ ::= Γ, x : τ (λx. e) v e[v/x] e 1 e 1 e 1 e

More information

Scala, Your Next Programming Language

Scala, Your Next Programming Language Scala, Your Next Programming Language (or if it is good enough for Twitter, it is good enough for me) WORLDCOMP 2011 By Dr. Mark C. Lewis Trinity University Disclaimer I am writing a Scala textbook that

More information

Topics Covered Thus Far CMSC 330: Organization of Programming Languages

Topics Covered Thus Far CMSC 330: Organization of Programming Languages Topics Covered Thus Far CMSC 330: Organization of Programming Languages Names & Binding, Type Systems Programming languages Ruby Ocaml Lambda calculus Syntax specification Regular expressions Context free

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques () Lecture 20 February 28, 2018 Transition to Java Announcements HW05: GUI programming Due: THURSDAY!! at 11:59:59pm Lots of TA office hours today Thursday See Piazza

More information

Chapter 13: Reference. Why reference Typing Evaluation Store Typings Safety Notes

Chapter 13: Reference. Why reference Typing Evaluation Store Typings Safety Notes Chapter 13: Reference Why reference Typing Evaluation Store Typings Safety Notes References Computational Effects Also known as side effects. A function or expression is said to have a side effect if,

More information

Verifying Concurrent ML programs

Verifying Concurrent ML programs Verifying Concurrent ML programs a research proposal Gergely Buday Eszterházy Károly University Gyöngyös, Hungary Synchron 2016 Bamberg December 2016 Concurrent ML is a synchronous language a CML program

More information

A Pragmatic Case For. Static Typing

A Pragmatic Case For. Static Typing A Pragmatic Case For Static Typing Slides available from github at: https://github.com/bhurt/presentations/blob/master /statictyping.odp Please Hold your Comments, Criticisms, Objections, Etc. To the end

More information

J. Barkley Rosser, 81, a professor emeritus of mathematics and computer science at the University of Wisconsin who had served in government, died

J. Barkley Rosser, 81, a professor emeritus of mathematics and computer science at the University of Wisconsin who had served in government, died Church-Rosser J. Barkley Rosser, 81, a professor emeritus of mathematics and computer science at the University of Wisconsin who had served in government, died Sept. 5, 1989. Along with Alan Turing and

More information

Part I Basic Concepts 1

Part I Basic Concepts 1 Introduction xiii Part I Basic Concepts 1 Chapter 1 Integer Arithmetic 3 1.1 Example Program 3 1.2 Computer Program 4 1.3 Documentation 5 1.4 Input 6 1.5 Assignment Statement 7 1.5.1 Basics of assignment

More information

The Algol family and ML

The Algol family and ML The Algol family and ML Jacopo Mauro mauro.jacopo@gmail.com Department of Informatics University of Oslo Initially by Gerardo Schneider, Volker Stolz. Based on John C. Mitchell s slides (Stanford U.) ML

More information

Recursion. Tjark Weber. Functional Programming 1. Based on notes by Sven-Olof Nyström. Tjark Weber (UU) Recursion 1 / 37

Recursion. Tjark Weber. Functional Programming 1. Based on notes by Sven-Olof Nyström. Tjark Weber (UU) Recursion 1 / 37 Tjark Weber Functional Programming 1 Based on notes by Sven-Olof Nyström Tjark Weber (UU) Recursion 1 / 37 Background FP I / Advanced FP FP I / Advanced FP This course (Functional Programming I) (5 hp,

More information

CS457/557 Functional Languages

CS457/557 Functional Languages CS457/557 Functional Languages Spring 2018 Lecture 1: Course Introduction Andrew Tolmach Portland State University (with thanks to Mark P. Jones) 1 Goals of this course Introduce the beautiful ideas of

More information

Functional Programming

Functional Programming Functional Programming Søren Haagerup Department of Mathematics and Computer Science University of Southern Denmark, Odense September 5, 2017 Practical Information The course is split in two I am responsible

More information

Software System Design and Implementation

Software System Design and Implementation Software System Design and Implementation Property-based Testing Gabriele Keller The University of New South Wales School of Computer Science and Engineering Sydney, Australia COMP3141 17s1 Testing in

More information

Polymorphism and Type Inference

Polymorphism and Type Inference Polymorphism and Type Inference Volker Stolz stolz@ifi.uio.no Department of Informatics University of Oslo Initially by Gerardo Schneider. Based on John C. Mitchell s slides (Stanford U.) Compile-time

More information

Type Inference. Prof. Clarkson Fall Today s music: Cool, Calm, and Collected by The Rolling Stones

Type Inference. Prof. Clarkson Fall Today s music: Cool, Calm, and Collected by The Rolling Stones Type Inference Prof. Clarkson Fall 2016 Today s music: Cool, Calm, and Collected by The Rolling Stones Review Previously in 3110: Interpreters: ASTs, evaluation, parsing Formal syntax Formal semantics

More information

8/27/17. CS-3304 Introduction. What will you learn? Semester Outline. Websites INTRODUCTION TO PROGRAMMING LANGUAGES

8/27/17. CS-3304 Introduction. What will you learn? Semester Outline. Websites INTRODUCTION TO PROGRAMMING LANGUAGES CS-3304 Introduction In Text: Chapter 1 & 2 COURSE DESCRIPTION 2 What will you learn? Survey of programming paradigms, including representative languages Language definition and description methods Overview

More information

3. Functional Programming. Oscar Nierstrasz

3. Functional Programming. Oscar Nierstrasz 3. Functional Programming Oscar Nierstrasz Roadmap > Functional vs. Imperative Programming > Pattern Matching > Referential Transparency > Lazy Evaluation > Recursion > Higher Order and Curried Functions

More information

Programming with Math and Logic

Programming with Math and Logic .. Programming with Math and Logic an invitation to functional programming Ed Morehouse Wesleyan University The Plan why fp? terms types interfaces The What and Why of Functional Programming Computing

More information

Programming Languages (CSCI 4430/6430) History, Syntax, Semantics, Essentials, Paradigms

Programming Languages (CSCI 4430/6430) History, Syntax, Semantics, Essentials, Paradigms Programming Languages (CSCI 4430/6430) History, Syntax, Semantics, Essentials, Paradigms Carlos Varela Rennselaer Polytechnic Institute August 30, 2016 C. Varela 1 The first programmer ever Ada Augusta,

More information

More Lambda Calculus and Intro to Type Systems

More Lambda Calculus and Intro to Type Systems More Lambda Calculus and Intro to Type Systems Plan Heavy Class Participation Thus, wake up! Lambda Calculus How is it related to real life? Encodings Fixed points Type Systems Overview Static, Dyamic

More information

Imperative languages

Imperative languages Imperative languages Von Neumann model: store with addressable locations machine code: effect achieved by changing contents of store locations instructions executed in sequence, flow of control altered

More information

Classical Themes of Computer Science

Classical Themes of Computer Science Functional Programming (Part 1/2) Bernhard K. Aichernig Institute for Software Technology Graz University of Technology Austria Winter Term 2017/18 Version: November 22, 2017 1/49 Agenda I Functional Programming?

More information

SOFTWARE VERIFICATION AND COMPUTER PROOF (lesson 1) Enrico Tassi Inria Sophia-Antipolis

SOFTWARE VERIFICATION AND COMPUTER PROOF (lesson 1) Enrico Tassi Inria Sophia-Antipolis SOFTWARE VERIFICATION AND COMPUTER PROOF (lesson 1) Enrico Tassi Inria Sophia-Antipolis Who am I? 1. I'm a researcher at Inria 2. I work on proof assistants, the kind of tools that we will be using for

More information

http://xkcd.com/224/ CS252 Programming Language Paradigms Prof. Tom Austin San José State University Fall 2014 What are some programming languages? Why are there so many? Different domains. Mobile devices

More information

Concepts in Programming Languages

Concepts in Programming Languages Concepts in Programming Languages Marcelo Fiore Computer Laboratory University of Cambridge 2012 2013 (Easter Term) 1 Practicalities Course web page: with lecture

More information

All you need is fun. Cons T Åhs Keeper of The Code

All you need is fun. Cons T Åhs Keeper of The Code All you need is fun Cons T Åhs Keeper of The Code cons@klarna.com Cons T Åhs Keeper of The Code at klarna Architecture - The Big Picture Development - getting ideas to work Code Quality - care about the

More information