1/11
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
What is functional programming?
a programming paradigm where code is written by applying and composing functions, avoiding side effects and mutable states
Advantages of functional programming
requirements are better defined as functions than complex steps - fewer errors during implementation
functions can be re-used within a program
no side effects → easier to debug and test
supports parallel/distributed processing (able to be used on big data)
Domain
All valid inputs for a function
Co-domain
The set of all possible outputs that a function could return
First-Class Objects
values that can be assigned to variables, passed as arguments, returned from functions and used in expressions
Higher-order functions
Functions that
take a function as an argument
and/or
return a function
Examples of higher-order functions
map, fold (reduce) and filter
Partial function application
Fixing one or more arguments of a function to produce a new function with fewer parameters
List Processing
splitting a list into the head (first index) and the tail (remaining elements)
Fold
Combines elements in a list into a singular value by repeatedly applying a function
Map
applies a function to each element in a list and returns a new list of results
filter
applies a function to each elements in a list, only keeping those that return True