O'Reilly logo
  • MINSHENG, TSAI thinks this is interesting:

Printing a String literal to a console is not pure as it modifies an external state.Reading a file is not pure as it depends on the external state at different times.Length of a String is pure as it does not rely on a state. It only takes a String as input and returns the length as output.Getting the current date is not pure as it returns different values when called at different dates.Getting a random number is not pure as it returns different values each time it is called.

From

Cover of Swift 3 Functional Programming

Note

QA