Practical numbers: Difference between revisions

m (→‎Composition of pure functions: Using type comments)
Line 180:
A composition of pure functions, including a more narrowly targeted test for subsets with a given sum in the ranges covered here.
 
Note that no type hints are added for the compiler in this example. The additional work of adding such hints can pay off with larger projects, particularly those involving several collaborators, but the cost/benefit (work for the coder, run-time startup cost) is known to be rather less clear at a small scale.
 
Clarity about the '''return type semantics''', is however, very useful when reasoning about pure functions, and my personal approach is to add light informal '''comments''' about the type, in a Hindley Milner idiom, which lends itself well to brief and clean notes on the type of '''curried''' functions, which I find more easily composable, especially with higher order functions, and generally prefer to use.
9,655

edits