3 ms·
> Mostly though, I love functional programming because it makes mucking around with data structures a lot easier. Can you talk more about that? My experience h
by bertiewhykovich 10y ago
> Mostly though, I love functional programming because it makes mucking around with data structures a lot easier.
Can you talk more about that? My experience has actually been largely the opposite: immutability actually makes working with data structures /harder/ for me. I'd be interested in hearing about any hidden advantages you've discovered there.
- deepGem 10y agoOne such example is the Scala List data structure. It's fundamentally a linked list but the built in routines for Lists such as zip, reduceLeft, map make it easier to transform List elements. By easier I mean, you write less code to do the same task as compared to an imperative program such as Java and without side effects.
- eudox 10y agoIn that case, though, the immutability is a property of the operations rather than the data. And you can have mutating versions of most of those operations that alter the data they are working on, e.g. a mutating map.