Functional Programming Final Review
CS16: Introduction to Data Structures & Algorithms Spring 2020
Functional Programming Final Review CS16: Introduction to Data - - PowerPoint PPT Presentation
Functional Programming Final Review CS16: Introduction to Data Structures & Algorithms Spring 2020 Functional Programming Paradigm A style of building the structure and elements of computer programs that treats computation as the
CS16: Introduction to Data Structures & Algorithms Spring 2020
computer programs that treats computation as the evaluation of mathematical functions.
smaller methods that do one part of a larger
using function compositions to accomplish the
2
(sub)-problems that involve doing the same thing to multiple elements.
new (smaller or larger) list
3
in the input list?
created outside of the map call if needed!
arguments written out.
4
map(lambda x: f(x), input_list) => map(f, input_list)
input list.
equal
5
a if condition else b
list?
6
the original list.
returns nothing.
7
into adverbs. (ex: loud -> loudly)
list of strings. (ex: [“hi”, “cs16”] -> 6)
times the string “dog” appears in a list of strings.
than 10 from a list of ints.
8
map(len, input_list), 0)
acc, input_list, 0))
acc, input_list, [])
9
CS16: Introduction to Data Structures & Algorithms Spring 2020
11
12
13
Sol
Sol Sol Sol Sol Sol Sol Sol Sol
14
Sol
Sol Sol Sol Sol Sol Sol Sol Sol
Why solve red twice? Why solve blue twice?
14
15
use?
16
a b c d f e 5 10 5 12
2 3 3 6