Florian
10/20/2019, 5:05 PMAdam Powell
10/20/2019, 7:14 PMFlorian
10/20/2019, 7:50 PMFlorian
10/20/2019, 7:50 PMArian Stolwijk
10/21/2019, 7:09 AMmap
/ filter
/ let
etc instead of for loops...
additionally you could keep your functions 'pure', meaning you don't really do side-effects in those functions.
Finally using the immutable datastructures also help with pure functions style...
and if all that functional code is inside a bigger class structure, doesn't make that smaller piece not functional imo.Florian
10/21/2019, 7:45 AMFlorian
10/21/2019, 7:45 AMFlorian
10/21/2019, 7:45 AMArian Stolwijk
10/21/2019, 7:48 AMFlorian
10/21/2019, 7:51 AMFlorian
10/21/2019, 8:09 AMRuckus
10/21/2019, 2:03 PMRuckus
10/21/2019, 2:07 PMalex
10/23/2019, 8:44 AMlist.map { ... }
is usually called functional, because map
is a functor: https://en.wikipedia.org/wiki/Map_(higher-order_function)#Generalization .
Imperative style would be:
for (int i = 0; i < list.size(); ++i) list[i] = map(list[i]);
.
It's the basics most of imperative programmers know, so it's enough for the start.
Some people do not really know functional programming and they refer to anything with chained calls (e.g. builder pattern) as functional, because it's easily recognizable, though it's not true in some cases.Florian
10/26/2019, 8:10 AM