July 2017
Intermediate to advanced
284 pages
6h 45m
English
So to a first approximation, functional programming is about programming with pure functions and immutable state, unlike imperative programming, which relies heavily on mutability. Around this immutable core there is a set of language techniques and features that replace mutable imperative techniques. Examining these will give us a deeper feeling for what it is to think and program functionally.
Let’s take a look at a simple example: filtering a list so it only contains odd numbers.
| | public List<Integer> filterOdds(List<Integer> list) { |
| | List<Integer> filteredList = new ArrayList<Integer>(); |
| | |
| | for(Integer current : list) { |
| | if(1 == current % 2) { |
| | filteredList.add(current); |
| | } |
| | } |
| | return filteredList; ... |
Read now
Unlock full access