Documente Academic
Documente Profesional
Documente Cultură
Functional Programming
Definition of Functional Programming
Where if FP used?
Brief history
Administrativia
Course overview
Bibliography
Evaluation
Basics of FP
Administrativia
Lectures
Assoc. prof. dr. eng. Radu Răzvan Slăvescu
Radu.Razvan.Slavescu@cs.utcluj.ro
Course Webpage
http://cs-gw.utcluj.ro/˜srazvan/fp/1819/fp1819.html
1. Lecture slides (in English) will be posted here every week
(or on Moodle)
2. Feedback appreciated
Definition
Functional Programming (FP) = a style of programming which
makes use of functions applied to arguments as basic blocks
for developing programs.
Remark
Functions have no side effects. In pure FP, there is no such a
thing as the ”state of the program”.
Remark
The arguments of a function could also be function calls, thus
building complex programs via function composition.
Definition
Program = Function
What is FP?
Definition (Implementation)
Implementation = a software toolkit which offers its users the
possibility to write programs in a functional manner
Why FP?
Miranda family
F#
I F# (Microsoft, for the .NET platform)
I Caml-like, but combines FP and OO approaches
C# and Python
I C#: immutability, function composition
I Python: lambdas, higher-order functions, lazy data-like
structures
Objectives
FP specific elements
I higher-order functions (anonymous functions, partial
application)
I infinite data and lazy evaluation
I transformation and reasoning on programs
I elements of Lambda calculus
Lab overview
ML: weeks 6 - 13
I practice writing Haskell and ML code
Bibliography
R. R. Slăvescu
Functional Programming - lecture notes.
Technical University of Cluj-Napoca, 2018.
I. A. Leţia, L. A. Negrescu, L. Negrescu
Programare funcţională, vol. I.
Ed. Albastră, Cluj-Napoca, Romania, 2006
I. A. Leţia
Programare funcţională.
UTPres, Cluj-Napoca, Romania, 1996
Bibliography - additional
G. Hutton
Programming in Haskell, 2nd edition.
Cambridge University Press, 2016
slides available from the course web page
Haskell wiki page
www.haskell.org
Bibliography - Lab
Exam
I 60 % of the final mark
I 2 problems/questions, one mark from 1 to 10 each
I If failed: repeated during the next session of exams
Two small Haskell examples
Erathostenes’ sieve
Quicksort
q [] = []
q (x:xs) = q [s | s <- xs, s<=x] ++
[x] ++
q [b | b <- xs, b>x]
Styles of interacting with computer