These are chat archives for ramda/ramda
I've got this same thoughts. (I am not ramda expert so I may be wrong)
converge -> Imho its usefull that you need to apply functions and then merge results of this functions together. Example: calculating avg score. First argument to converge is function which will 'merge/connect' result of the array of function passed in 2nd argument.
R.converge(R.divide, [R.sum, R.length]) . So first step is that you got result from sum and length, and its passed to 'merge' function -> and the end you finish with ONE result
AP is different -> Firstly you will not end with one result, but an array. and as you have mention it just apply functions on a data set.. And its JUST concatenated,
R.ap([R.multiply(2), R.add(3)], [1,2,3]); First step apply R.multiply, and you get [2,4,6], 2nd step [4,5,6], concatenate and you got final result [2,4,6,4,5,6]
Of course you can also write AP, using converage with 'merge' function set to 'contact'
R.converge(R.concat, [R.map(R.multiply(2)), R.map(R.add(3))])([1,2,3])
For me converge is like 'splitting' value to two functions, do some calculations, and merge them back (I've noticed its usefull for point free, if you need to get the argument in two or more places)
const isPalindrome = R.ap(R.equals, R.reverse)('test')i don't understand how this works
const isPalindrome = s => s === R.reverse(s)is much easier to understand
Also treats curried functions as applicatives.
aprather than arrays they get treated like this:
const h = f => g => x => f(x, g(x));
R.ap(R.equals, R.reverse) === x => R.equals(x, R.reverse(x))
R.converge(R.add, [R.idenity, R.idenity])(10) === R.ap(R.add, R.identity)(10)
const palindrome = R.converge(R.equals, [R.identity, R.reverse])
R.converge(R.add, [R.identity, R.identity])(10)
R.converge(f, [R.identity, g])you can use