You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ref: The forgotten functional pattern by Ben Deane for deeply functional topic
10
+
11
+
Paradigms:
12
+
13
+
- Imperative or Procedual: roots with c
14
+
- Object Oriented: roots with simula
15
+
- Functional: STL, Lambdas, Ranges
16
+
17
+
## Identifying code functionally
18
+
19
+
Functional Code Categories:
20
+
21
+
- Actions: Depend on when or how many times they are called. Observable changes occur.
22
+
- Calculation: Depend only on their inputs and not when or how they are called. Calling them with the same inputs always results in the same outputs. No observable changes occur.
23
+
- Data: Unchanging records od events. Used as input to calculations and actions. Records the results of calculations adn actions.
24
+
25
+
- Actions
26
+
- Allow input to programs that is unknown when the program was written
27
+
- Performing an action has consequences
28
+
- Affect how a program executes
29
+
- Calculation
30
+
- Reliable
31
+
- Encapsulated, has no effect outside of itself
32
+
- Thread safe, since it is entirely salf contained, no ordering or locking is necessary
33
+
- Data
34
+
- Fundamental building block
35
+
- Immutable, data doesn't change
36
+
- Transparent, you can look at data and see what it is
37
+
- Open to interpretation, data can mean different things to different components without changing value
38
+
- Used by calculations and actions to communicate with other calculations and actions
39
+
40
+
Data is all about context
41
+
42
+
Breaking down a problem to actions, calculations and data.
43
+
44
+
std::copy_if
45
+
46
+
## Functions as Data
47
+
48
+
Passing functions to functions
49
+
50
+
Return functions from functions
51
+
52
+
currying: transform a function of several arguments to a function of a single argument.
0 commit comments