These are chat archives for ramda/ramda

Mar 2018
Mar 06 2018 00:14
I'm curious if there's a better way to use R.juxt with lists than having to R.apply() it first...
map(R.apply(R.juxt([toUpper, toLower])), [['Foo', 'Bar']]);
not readable enough for me :worried:
Mar 06 2018 00:19
zipWith(call, [toUpper, toLower], ['Foo', 'Bar’])
@miwillhite this is awesome, btw
Matthew Willhite
Mar 06 2018 02:15
Mar 06 2018 02:23
oddly enough I never saw a call to .filter in the source code. only to .length
"A value which has a Filterable" .. that doesnt seem like how ramda works thou. for the most part you don't call methods on objects , do you?
Matthew Willhite
Mar 06 2018 04:00
ah yeah you are right @jay-jlm, the implementation conflicts with the Filterable spec
In fact Filterable was added only 2 months ago, so ramda’s Filterable reference wouldn’t even be aware of the FL spec
That reference was written 2 years ago :grin:
Shawn Talbert
Mar 06 2018 04:30
imho it's bad form to call out a type 'Filterable' without any information on what that is :(
my impression is it can be an object or an array (only) then I discovered code referring to tranducers...
Somehow Ramda (map()/filter()) handles observables correctly(?) but I don't see how - since an Observable is neither an array or an object whose keys you want to iterate over.
Mar 06 2018 04:35
Guess I misread what was there, I went straight to the "filter method" sub-section but that's just for when you want to implement a filter method on your a data structure. The actual functional specification of how it should work is listed above that.
@ShawnTalbert , it does say it right there in the docs thou. " Filterable objects include plain objects or any object that has a filter method such as Array"
Simon Friis Vindum
Mar 06 2018 08:15
@sourcevault I just saw that you asked if I was planning on adding POJO support to List? What do you mean exactly?
Mar 06 2018 12:51
what's the best what to short-circuit a mapping? Or a forEach(), for that matter
basically I'm looking for a way to compare a string with an array of values that look like this (compares with the string, returns the number): [ ['a', 1 ], ['b', 2] [ 'aa', 3 ] ].. however because there could be multiple matchings I want to short-circuit on the first match
Mar 06 2018 13:31
btw, there's no way to short-cirtcuit Array.forEach it seems... Array.some would work:
Mar 06 2018 13:37
Here's what I'm trying to do. (It works but there must be a better way) :
const myMap = [
  ['a', 'expected output'],
  ['aa', 'no short-circuit'],
  ['aaa', 'no short-circuit'],
const findFirstMatch = str => {
  let found = 'not found'
  myMap.some(el => {
    if( R.contains(el[0], R.toLower(str)) ) {
      found = el[1]
      return true
  return found
Kurt Milam
Mar 06 2018 13:47
@jay-jlm use R.reduce together with R.reduced for more complex requirements, but for this, it seems R.find (or even Array.prototype.find) would work?
Mar 06 2018 15:07
@kurtmilam , ok I will test it soon
Mar 06 2018 15:27
how can I split a list based on function... i tried splitWhen but that only returns two lists
basically I need to run a predicate function and whenever the predicate returns a given boolean the list will be split of that point. This would return a list of lists
Mike Lambert
Mar 06 2018 15:32
hmm, i wonder if you can use splitWhen recursively or with reduce somehow...
Mar 06 2018 15:33
yeah, that might work.
Matthew Willhite
Mar 06 2018 18:50
I’ve used splitWhen recursively to do what you are saying
a list of objects had a flag, depending on the value of that flag I needed to split and keep going
Mar 06 2018 19:24
@kurtmilam Yes, find would work as a replacement of the code I posted above. Thank you!
@miwillhite sounds super annoying to code :D
Mar 06 2018 19:31
@miwillhite group with would work, I think:
R.groupWith(R.flip(R.modulo)(3), [ 1, 2, 3, 4, 5, 6, 7, 8])  // => [[1, 2, 3], [4, 5, 6], [7, 8]]