/***************************************************************************************
** Author: Guillaume ARM ***************************************************************
** F.js: is little library utilites made for doing functional coding style with JS. ****
***************************************************************************************/

export const _ = undefined

/////////////////////// PRIVATE ////////////////////////////////////////////////
const isUndefined = x => (x === _)
const concatUndefined = xsa => xsb =>
	xsa.map(x => !isUndefined(x) ? x : xsb.shift()).concat(xsb)
////////////////////////////////////////////////////////////////////////////////


export const curry = (f, ...xs) =>
	xs.length === f.length
		? f(...xs)
		: curry.bind(this, f, ...xs)

export const apply = (f, ...xs) => (...otherXs) =>
	f.apply (this, concatUndefined (xs) (otherXs) )

export const compose = f => g => x => f(g(x))


export const update = obj => (...changes) => Object.assign({}, obj, ...changes)

export const foldl = f => acc => xs => xs.reduce(f, acc)
export const foldr = f => acc => xs => xs.reverse().reduce(f, acc)

export default {curry, apply, compose, update, foldl, foldr, _}


@@ -405,17 +405,179 @@
 ////
- PRIVATE 
+/////////////////////////////////////////////////////////%0A/////////////////////// PRIVATE ////////////////////////////////////////////////%0A////////////////////////////////
 ////
@@ -755,16 +755,17 @@
 at(xsb)%0A
+%0A
 ////////
@@ -837,16 +837,177 @@
 ///////%0A
+/////////////////////// USEFUL FOR COMPOSITION /////////////////////////////////%0A////////////////////////////////////////////////////////////////////////////////
 %0A%0Aexport
@@ -1251,18 +1251,16 @@
 f(g(x))%0A
-%0A%0A
 export c
@@ -1457,16 +1457,322 @@
 , acc)%0A%0A
+////////////////////////////////////////////////////////////////////////////////%0A/////////////////////// USEFUL FOR COMPOSITION /////////////////////////////////%0A////////////////////////////////////////////////////////////////////////////////%0Aexport const incr = x =%3E x + 1%0Aexport const decr = x =%3E x - 1%0A%0A
 export d
@@ -1779,16 +1779,22 @@
 efault %7B
+%0A%09_,%0A%09
 curry, a
@@ -1815,17 +1815,18 @@
  update,
- 
+%0A%09
 foldl, f
@@ -1834,9 +1834,21 @@
 ldr,
- _%7D
+%0A%09incr, decr%0A%7D%0A
 %0A%0A

add incr and decr functions