Going Functional Primož Gabrijelčič. Functional programming.

Slides:



Advertisements
Similar presentations
Introduction to Compilation of Functional Languages Wanhe Zhang Computing and Software Department McMaster University 16 th, March, 2004.
Advertisements

”Life is too short for imperative programming” John Hughes.
1 Scheme and Functional Programming Aaron Bloomfield CS 415 Fall 2005.
Chapter 5: Abstraction, parameterization, and qualification Xinming (Simon) Ou CIS 505: Programming Languages Kansas State University Fall
Comp 205: Comparative Programming Languages Functional Programming Languages: More Haskell Nested definitions Lists Lecture notes, exercises, etc., can.
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.
Refactoring in (and out of) Delphi Primož Gabrijelčič.
MATHEMATICAL FOUNDATIONS SUPPLEMENTAL MATERIAL – NOT ON EXAM.
Chapter 10 Recursion Instructor: alkar/demirer. Copyright ©2004 Pearson Addison-Wesley. All rights reserved.10-2 Recursive Function recursive functionThe.
4. Functional Programming. © O. Nierstrasz PS — Functional Programming 4.2 Roadmap Overview  Functional vs. Imperative Programming  Pattern Matching.
Functional Design and Programming Lecture 1: Functional modeling, design and programming.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 14 Functional Programming It is better to.
4. Functional Programming. © O. Nierstrasz PS — Functional Programming 4.2 Roadmap  Functional vs. Imperative Programming  Pattern Matching  Referential.
Introducing the Erlang Language Why Erlang?  Exemplifies the “you can have code and concurrency that is free from side effects…there is no other way”
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Introduction to Functional Programming Notes for CSCE 190 Based on Sebesta,
Presented by Neng-Fa Zhou1 Evolution of programming languages –Machine language –Assembly language –Sub-routines and loop (Fortran) –Procedures and recursion.
Programming Paradigms Imperative programming Functional programming Logic programming Event-driven programming Object-oriented programming A programming.
Interlude: Functional Programming CSE 331 Section 2 James Daly.
CS 2104 : Prog. Lang. Concepts. Functional Programming I Lecturer : Dr. Abhik Roychoudhury School of Computing From Dr. Khoo Siau Cheng’s lecture notes.
Programovací jazyky F# a OCaml Chapter 5. Hiding recursion using function-as-values.
Functional Programing Referencing material from Programming Language Pragmatics – Third Edition – by Michael L. Scott Andy Balaam (Youtube.com/user/ajbalaam)
Com Functional Programming Higher Order Functions and Computation Patterns (I) Marian Gheorghe Lecture 10 Module homepage Mole &
The College of Saint Rose CIS 433 – Programming Languages David Goldschmidt, Ph.D. from Concepts of Programming Languages, 9th edition by Robert W. Sebesta,
Algorithmic Recursion. Recursion Alongside the algorithm, recursion is one of the most important and fundamental concepts in computer science as well.
0 REVIEW OF HASKELL A lightening tour in 45 minutes.
1 COMP313A Functional Programming (1). 2 Main Differences with Imperative Languages Say more about what is computed as opposed to how Pure functional.
1 Programming Languages and Paradigms Functional Programming.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 7.
Fixed Point Illustrations. Simple Examples f : int -> int f(n) = 5 n = 5 is a unique fixed point. f(n) = n^2 – 2 n = 2 and n = -1 are both fixed points.
Chapter Fifteen: Functional Programming Languages Lesson 12.
Functional Programming Language OCaml Tutorial 科大 - 耶鲁联合研究中心
TIVDM2Functional Programming Language Concepts 1 Concepts from Functional Programming Languages Peter Gorm Larsen.
COMP313A Functional Programming (1)
CMSC 330: Organization of Programming Languages Maps and Folds Anonymous Functions.
Lee CSCE 314 TAMU 1 CSCE 314 Programming Languages Interactive Programs: I/O and Monads Dr. Hyunyoung Lee.
PPL Lecture 3 Slides by Yaron Gonen, based on slides by Daniel Deutch and lecture notes by Prof. Mira Balaban.
First Order Haskell Neil Mitchell York University λ.
CS5205Haskell1 CS5205: Foundation in Programming Languages Basics of Functional Programming.
Functional Programming IN NON-FUNCTIONAL LANGUAGES.
Just do It: Simple Monadic Equational Reasoning Jeremy Gibbons and Ralf Hinze, 2011 José Serra Thematic Seminar June 2012.
Interpreters and Higher-Order Functions CSE 413 Autumn 2008 Credit: CSE341 notes by Dan Grossman.
Haskell Introduction CSCE 314 Spring CSCE 314 – Programming Studio Historical Background 1930s: Alonzo Church develops the lambda calculus, a simple.
An Introduction to F# Sushant aboutdev.com
CSE 425: Functional Programming I Programs as Functions Some programs act like mathematical functions –Associate a set of input values from the function’s.
Haskell Chapter 5, Part II. Topics  Review/More Higher Order Functions  Lambda functions  Folds.
1.SML Docs Standard Basis 2.First-Class Functions Anonymous Style Points Higher-Order 3.Examples Agenda.
chap10 Chapter 10 Recursion chap10 2 Recursive Function recursive function The recursive function is a kind of function that calls.
CSE-321 Programming Languages Introduction to Functional Programming POSTECH March 8, 2006 박성우.
Introduction to Concepts in Functional Programming CS16: Introduction to Data Structures & Algorithms Thursday, April 9,
Introduction to Functional Programming Part 1 – The Basic Concepts Winter Young
Programming Paradigms, Software Architectural Patterns, and MVC CS 378 – Mobile Computing for iOS Dr. William C. Bulko.
Functional Programming
CS314 – Section 5 Recitation 9
Functional Programming
Introduction to Higher Order (Functional Programming) (Python) part 2
Chapter 10 Recursion Instructor: Yuksel / Demirer.
Functional Programming
Theory of Computation Lecture 4: Programs and Computable Functions II
Organization of Programming Languages
Main Points of Haskell Functional programming Laziness
Objective caml Daniel Jackson MIT Lab for Computer Science 6898: Advanced Topics in Software Design March 18, 2002.
Overview of Programming Paradigms
Programming Languages
Functional Programming
Small Basic Programming
Write the recursive and explicit formula for the following sequence
Lambda Expressions Cases
Presentation transcript:

Going Functional Primož Gabrijelčič

Functional programming

Computation = evaluation of (mathematical) functions Based on lambda calculus No state No mutable data No side effects

Functional vs. imperative Imperative programming –Functions can have side effects Functional programming –Output depends only on the input arguments

Functional programming Immutable variables Pattern matching Higher-order functions Recursion

Functional programming in Delphi

Immutable variables - hard Pattern matching – if / case Higher-order functions – anonymous methods Recursion – plain old pascal

Anonymous methods Nameless methods Can be stored in a variable, field, passed as parameter … Internally implemented as an interface

Anonymous methods Binding variable values Easy way to define and use methods Easy to parameterize using code Anonymous_Methods_in_Delphihttp://docwiki.embarcadero.com/RADStudio/en/ Anonymous_Methods_in_Delphi

Hands-on

Inline versus anonymous

Reversing a list in Haskell reverse :: [a] -> [a] reverse [] = [] reverse (x:xs) = reverse xs ++ [x]

Fibonacci sequence in Haskell fibRecurrence first second = first : fibRecurrence second (first + second) fibonacci = fibRecurrence 0 1 main = print (fibonacci !! 10)

Questions?