SlideShare a Scribd company logo
Purely Functional 
Data Structures 
Jean-Baptiste Mazon 
Riviera Func 2013-05-21
OHAI 
Jean-Baptiste Mazon 
@jbmazon 
Sophia-Antipolis 
PL 
(Google Docs)
Purely Functional Data Structures 
About — What — Why — How
Persistence 
● ephemeral 
● partially persistent 
● fully persistent 
● confluently persistent 
immutable data ⇒ fully persistent structures
Persistence: linked lists
Persistence: concatenated lists
Persistence: binary search tree
Persistence: insertion
Amortization 
Mutable textbook example: autosized vector 
Okasaki examples: 
● queues 
● binomial heaps 
● splay heaps 
● pairing heaps
Naive queue 
1 2 3 n-2 n-1 n
Amortized queue 
1 2 3 
n n-1 n-2 
...breaks with persistence
Persistence and Amortization 
execution trace 
expensive operation 
call-by-value 
call-by-name 
call-by-need 
stream
Lazy Evaluation 
1 2 3 
1 2 3 
f 
r
Persistent Amortized Queue 
1 f r 1 
better than amortized?
Realtime Queue 
problem with reverse 
rotate(f,r,a) = f ++ reverse(r) ++ a 
rotate(f|fs,r|rs,a) = f | rotate(fs,rs,r|a) 
“scheduling”
Numerics 
Lists 
List = 
● Empty 
● Cons(e,List) 
Peano arithmetic 
Nat = 
● Zero 
● Succ(Nat)
Numerics: random access list 
0 1 2 3 4 5 6 , , 
… but cons, head, tail are O(lg N)
Numerics: zeroless 
how 
consequence on list 
consequence on first tree 
head O(1) 
tail and cons O(1)?
Numerics: redundancy 
22222 
111111 
011111
Numerics: quaternary
But wait, there's more! 
● not only queues 
● skew binary 
● bootstrapping 
● implicit recursive 
slowdown
KTHXBYE
Image Credits 
Alexberlioz [CC-BY-SA-3.0], from Wikimedia 
Commons 
Marc NL [Public domain], from Wikimedia 
Commons 
J.J. [CC-BY-SA-3.0], from Wikimedia Commons

More Related Content

PDF
CAP简介
PDF
N20190530
PPTX
STL - Map, Set, Vector
PDF
R language, an introduction
PPTX
CS151 FIle Input and Output
PDF
Multiple Dispatch
ODP
Untitled talk at Riviera.rb
ODP
Turing-complete templates for everyone!
CAP简介
N20190530
STL - Map, Set, Vector
R language, an introduction
CS151 FIle Input and Output
Multiple Dispatch
Untitled talk at Riviera.rb
Turing-complete templates for everyone!

Similar to Purely Functional Data Structures (20)

PPTX
Immutable data structures - A Primer
PDF
Advanced Algorithms Lecture Notes Mit 6854j Itebooks
PDF
Efficient Immutable Data Structures (Okasaki for Dummies)
PPTX
Dev Concepts: Data Structures and Algorithms
PDF
Functional data structures
PDF
Purely functional data structures demystified
DOC
Data structure-questions
PPT
Data Structures and Algorithm for Engineers.ppt
PPT
DATA STRUCTURES IN INFORMATION TECHNOLOGY
PPT
DSA theory all topics (summary) presentation
PPT
02-dataStructurePM and algortima for python.ppt
PPT
Basic Data Structure and its concepts details
PPT
different types of data structures using c.ppt
PDF
Questions datastructures-in-c-languege
PPT
data structure in programing language.ppt
PPT
PMDATA STRUICVIUDGHfjufguigfuigkguidfui.ppt
PPT
10 Linked Lists Sacks and Queues
Immutable data structures - A Primer
Advanced Algorithms Lecture Notes Mit 6854j Itebooks
Efficient Immutable Data Structures (Okasaki for Dummies)
Dev Concepts: Data Structures and Algorithms
Functional data structures
Purely functional data structures demystified
Data structure-questions
Data Structures and Algorithm for Engineers.ppt
DATA STRUCTURES IN INFORMATION TECHNOLOGY
DSA theory all topics (summary) presentation
02-dataStructurePM and algortima for python.ppt
Basic Data Structure and its concepts details
different types of data structures using c.ppt
Questions datastructures-in-c-languege
data structure in programing language.ppt
PMDATA STRUICVIUDGHfjufguigfuigkguidfui.ppt
10 Linked Lists Sacks and Queues
Ad

Recently uploaded (20)

PDF
Sciences of Europe No 170 (2025)
PDF
bbec55_b34400a7914c42429908233dbd381773.pdf
PDF
Phytochemical Investigation of Miliusa longipes.pdf
PPTX
microscope-Lecturecjchchchchcuvuvhc.pptx
PDF
Mastering Bioreactors and Media Sterilization: A Complete Guide to Sterile Fe...
PPTX
INTRODUCTION TO EVS | Concept of sustainability
PPTX
Introduction to Fisheries Biotechnology_Lesson 1.pptx
PPTX
Classification Systems_TAXONOMY_SCIENCE8.pptx
PPTX
Derivatives of integument scales, beaks, horns,.pptx
PDF
IFIT3 RNA-binding activity primores influenza A viruz infection and translati...
PPTX
2Systematics of Living Organisms t-.pptx
PPTX
Microbiology with diagram medical studies .pptx
PPT
protein biochemistry.ppt for university classes
PPTX
famous lake in india and its disturibution and importance
PDF
VARICELLA VACCINATION: A POTENTIAL STRATEGY FOR PREVENTING MULTIPLE SCLEROSIS
PPTX
GEN. BIO 1 - CELL TYPES & CELL MODIFICATIONS
PPTX
ANEMIA WITH LEUKOPENIA MDS 07_25.pptx htggtftgt fredrctvg
PDF
The scientific heritage No 166 (166) (2025)
PPTX
EPIDURAL ANESTHESIA ANATOMY AND PHYSIOLOGY.pptx
PDF
Biophysics 2.pdffffffffffffffffffffffffff
Sciences of Europe No 170 (2025)
bbec55_b34400a7914c42429908233dbd381773.pdf
Phytochemical Investigation of Miliusa longipes.pdf
microscope-Lecturecjchchchchcuvuvhc.pptx
Mastering Bioreactors and Media Sterilization: A Complete Guide to Sterile Fe...
INTRODUCTION TO EVS | Concept of sustainability
Introduction to Fisheries Biotechnology_Lesson 1.pptx
Classification Systems_TAXONOMY_SCIENCE8.pptx
Derivatives of integument scales, beaks, horns,.pptx
IFIT3 RNA-binding activity primores influenza A viruz infection and translati...
2Systematics of Living Organisms t-.pptx
Microbiology with diagram medical studies .pptx
protein biochemistry.ppt for university classes
famous lake in india and its disturibution and importance
VARICELLA VACCINATION: A POTENTIAL STRATEGY FOR PREVENTING MULTIPLE SCLEROSIS
GEN. BIO 1 - CELL TYPES & CELL MODIFICATIONS
ANEMIA WITH LEUKOPENIA MDS 07_25.pptx htggtftgt fredrctvg
The scientific heritage No 166 (166) (2025)
EPIDURAL ANESTHESIA ANATOMY AND PHYSIOLOGY.pptx
Biophysics 2.pdffffffffffffffffffffffffff
Ad

Purely Functional Data Structures