News for hackers. Stuff that matters.
Re:Functional Programming in 5 Minutes by jarek-foksa on Sunday May 19, 2013 @04:59PM (#5734368)
In FP functions shouldn't mutate data structures that were passed by reference on input, instead any input data should be copied before performing mutations on it to avoid changes to external state.

This is how e.g. Array.prototype.filter() works in JavaScript:

  var numbers = [1,2,3,4,5,6,7,8,9,10];

  var evenNumbers = numbers.filter( function(number) {
    return number % 2 === 0;
  });
Re:Functional Programming in 5 Minutes by chousuke on Sunday May 19, 2013 @05:16PM (#5734420)
I would like to add that this it is perfectly possible to write purely functional programs that do mutation. You just need to be explicit about it.

Many purely functional data structures also have advanced implementations that need much less copying than "immutable" would at first make you think, since two values can share unchanged structure.

Re:Functional Programming in 5 Minutes by Peaker on Sunday May 19, 2013 @05:07PM (#5734394)
It's not really considered "mutation" at all. They just return new values that are related in some way to the input values.