These are chat archives for ramda/ramda

Dec 2016
Dec 14 2016 02:21
Just learning ramda and came across something very strange to me trying to find duplicate values in an array.
Why would adding a tap make the following methods behave differently?
const R = require('ramda');

const trace = R.tap( x => console.log(x) );

const firstLastIndexDifferent = R.curry( (list, value) => {
  return R.not( R.equals( R.indexOf(value, list), R.lastIndexOf(value, list)));

const find         = R.converge( R.find, [ firstLastIndexDifferent, R.identity ]);
const findComposed = R.converge( R.find, [ R.compose(firstLastIndexDifferent ), R.identity ]);
const findTraced   = R.converge( R.find, [ R.compose(firstLastIndexDifferent, trace ), R.identity ]);

console.log('find:'+find([1,2,3,4,3])); //find:function (a0) { return fn.apply(this, arguments); }
console.log('findComposed:'+findComposed([1,2,3,4,3])); //findComposed:function (a0) { return fn.apply(this, arguments); }
console.log('findTraced:'+findTraced([1,2,3,4,3]));  //findTraced:3
Brad Compton (he/him)
Dec 14 2016 02:43
@jxl118 Not sure what the root cause is, but curry is your culprit. Adding the trace to the beginning forces firstLastIndexDifferent to be treated as a unary function.
OH, I got it!!!
converge bases the number of arguments it expects on the max number accepted by any of the branching functions.
curry will maintain a Function.length of 2 for firstLastIndexDifferent
As a result, your find and findComposed functions are both curried to take 2 arguments
Dec 14 2016 17:28
@Bradcomp Thanks for the fix and explanation
Daniel Tsui
Dec 14 2016 20:42
Quick question: I want to associate multiple props to an object. Besides (i) composing assoc, and (ii) using merge with a new object, what other operations do I have available to me?
Rob Halff
Dec 14 2016 21:42
this oughta work export myFunc from './myFunc' using curry
I guess babel doesn't prevent doing any of those things.
Kliment Mamykin
Dec 14 2016 22:17
cant figure out how to group list by a predicate which is applied to adjasent elements in the list, e.g [0,1,2,3,1,2,0,4,5,6,9] -> [[0,1,2,3],[1,2],[0],[4,5,6],[9]] (with predicate (a,b) => a+1==b)
Kliment Mamykin
Dec 14 2016 23:50
for ^^ created ramda/ramda#2012