From 2fbc65d2c35335ef769427aa2d307c9e592a9be2 Mon Sep 17 00:00:00 2001 From: Scott Sauyet Date: Mon, 21 Sep 2015 21:26:45 -0400 Subject: [PATCH] New points-free example and discussion --- readme.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 116e0e0..6d97dcd 100644 --- a/readme.md +++ b/readme.md @@ -119,14 +119,27 @@ executions with the the same input parameters. --- -## Point Free +## Points-Free > A function whose definition does not include information regarding its arguments. ```js -let abs = Math.abs +// Given +let combine = curry((fn, initialVal, list) => list.reduce(fn, initialVal)); +let add = (a, b) => a + b; + +// Then + +// Not points-free +let total1 = (numbers) => combine(add, 0, numbers); + +// Points-free +let total2 = combine(add, 0); ``` +`total1` lists and uses the parameter `numbers`, so it is not points-free. `total2` is written just by combining functions and values, making no mention of its arguments. It _is_ points-free. + +It is easy to recognize points-free function definitions; they are the ones that contain no '`function`' keywords and no fat arrows. --- ## Contracts