7. "Functional code is characterised by one thing: the absence of
side effects. It doesn’t rely on data outside the current
function, and it doesn’t change data that exists outside the
current function. Every other “functional” thing can be derived
from this property. Use it as a guide rope as you learn.”
- - Mary Rose Cook
- https://maryrosecook.com/blog/post/a-practical-introduction-to-functional-
programming
18. "A pure function is a function that, given the same input, will
always return the same output and does not have any
observable side effect."
- Professor Franklin Risby's
- Mostly Adequate Guide to Functional Programming
19. fun add(x: Int): Int {
val y: Int = readNumFromFile()
return x + y
}
Impure
23. "The name of a variable, function or class should answer the
big questions such as why it exists, what it does, how it is
used."
Aiden Mc Raft commenting Robert C. Martin’s Clean Code: A
Handbook of Agile Software Craftsmanship
31. fun applyOperation(operation: Operation): (Int, Int) -> Int {
val add = fun (x: Int, y: Int) = x + y
val sub = fun (x: Int, y: Int) = x - y
when (operation) {
Operation.ADD -> return add
Operation.SUB -> return sub
}
}