Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 31 22:17
    CrossEye commented #2779
  • Jan 31 21:04
    ArturAralin commented #2779
  • Jan 31 20:08
    CrossEye commented #2779
  • Jan 31 18:56
    buzzdecafe commented #2631
  • Jan 31 18:09
    ArturAralin commented #2779
  • Jan 31 16:18
    CrossEye commented #2779
  • Jan 31 16:10
    CrossEye commented #2631
  • Jan 31 16:06
    CrossEye commented #2777
  • Jan 31 14:44
    ArturAralin opened #2779
  • Jan 31 07:39
    inferusvv commented #2631
  • Jan 31 03:07
    sespinozj commented #2771
  • Jan 31 02:33
    machad0 commented #2771
  • Jan 31 02:26
    JeffreyChan commented #2777
  • Jan 30 14:30
    CrossEye closed #2777
  • Jan 30 12:13
    vanyadymousky updated the wiki
  • Jan 30 01:42
    JeffreyChan commented #2777
  • Jan 29 21:06
    vanyadymousky updated the wiki
  • Jan 29 16:28
    CrossEye commented #2777
  • Jan 29 15:50
    mbostock commented #2772
  • Jan 29 15:48
    CrossEye commented #2772
coffeefedora
@coffeefedora
I wonder if I setup the vals right, i can use mergeAll?
Dmitri Zaitsev
@dmitriz
Object merge can now be done with spread
but of course you can use ramda if you prefer
coffeefedora
@coffeefedora
not sure is spread is in IE 11
and what does ramda call spread? i looked for that
Dmitri Zaitsev
@dmitriz
ramda has some merging functions but I have no idea since I just use spread
but it may not be supported by some old browsers, you need to check that
or use ramda, if that is supported
but it doesn't change on the issue of purity
in principle, you can still write non-pure functions in functional style of course
Dmitri Zaitsev
@dmitriz
x => array => {array.push(x); return array}
coffeefedora
@coffeefedora
right, which is what i do for some tree stuff
Dmitri Zaitsev
@dmitriz
but notice my function returns
so you can return your tree
Dale Francis
@dalefrancis88
@dmitriz compose/pipe are actually just wrappers around reduceRight(B)/reduce(B)
the power in combinators really comes into play further down the track as you have all you're small utility functions and can start to bring them together. converge is where i've seen some people begin to reach for the power of combinators
Dmitri Zaitsev
@dmitriz
@dalefrancis88 Doesn't convergehave the limitation of all functions in the array accepting the same arguments?
For instance, converge(f, [g,h])(x,y)requires both g and h to accept (x,y).
Dmitri Zaitsev
@dmitriz
Also maybe both compose and converge can be unified into arbitrary pipelines containing functions or arrays of functions. Which would be wrappers around reduce as you point out, so we only need a pipe(a,b), where each of a,b is either a function or an array of functions.
akillingbeck89
@akillingbeck89

Hey guys, having a strange issue with Ramda here...basically I'm trying to remove an item from an array if it's already there, and add it if it's not. I replaced the ramda code with standard JS and it worked instantly, unsure what's wrong with the setup here:

const newSelections = R.pipe(
        R.path(['selectedSections']),
        R.ifElse(R.contains(payload), R.without(payload), R.append(payload))
      )(state)
      return R.assoc('selectedSections', newSelections, state)

So without should remove payload if selectedSections contains it, I've debugged the input, it's all fine and correct. Also thought it might be a case of modifying the original array while iterating, so I attempted a deep clone of selectedSections too (which didn't work)

Riku Tiira
@rikutiira
first argument of R.without should be an array of values you want to omit
akillingbeck89
@akillingbeck89
Sorry, I should have mentioned, it generally works, but when selecting a section whose string might contain a sub-string of others, all of the others get deselected to.
Riku Tiira
@rikutiira
if your payload is an array then not sure what’s wrong there
also, you could replace the whole thing with return R.evolve({ selectedSections: R.ifElse(R.contains(payload), R.without(payload), R.append(payload)) }, state)
akillingbeck89
@akillingbeck89
Yeah it is an array, ok cheers I'll give that a go
Cool that worked, thanks :)
Bijoy Thomas
@bijoythomas
hello, is there a combinator whose signature is like: (a => b => c) => (x => a) => (y => b) => x => y => c .. kinda like useWith or can this be built from the basic combinators?
Dale Francis
@dalefrancis88
@bijoythomas not in Ramda but there is one in crocksit's called compose2 https://crocks.dev/docs/functions/combinators.html#compose2
Bijoy Thomas
@bijoythomas
@dalefrancis88 thank you
Dale Francis
@dalefrancis88
np :)
mitcho
@mitchoSR_twitter
anyone know of an R function thats like reduce but just repeats x times something like this, seems very useful for generating data const reduceXTimes = (fn,init) => num => { for(let i = 0; i < num; i++) init = fn(init,i); return init; }
also does anyone know of a higher order function that takes 2 arrays and supplies one to a callback that iterates over the other and reduces
dont need them, just curious if they exist
Kurt Milam
@kurtmilam
mitcho
@mitchoSR_twitter
neato, thank you
Kurt Milam
@kurtmilam
Not sure exactly how the second one is supposed to work.
Brad Compton (he/him)
@Bradcomp
There's also R.reduceWhile
Charles Hughes
@chughes87
Hey all, I'm trying to use pipe with ifElse. I'm trying to define a pipeline and utilizing it conditionally with ifElse. However, the default arity of pipe seems to be 3 for some reason and that is messing with the ifElse... For more context on ifElse's arity behavior: ramda/ramda#2654. Is there some workaround for this that isn't super ugly? Im enforcing arity of one with an inline (input) => pipeFn(input) right now
mitcho
@mitchoSR_twitter
@Bradcomp thanks, that looks great too
Ben Briggs
@ben-eb
@chughes87 You can use o which is unary composition, note it will only accept two functions unlike pipe which is variadic
Also there is the unary helper which you could do instead of your arrow
Charles Hughes
@chughes87
great thank you for the tips!
coffeefedora
@coffeefedora
is there a way to define a function with all of its params, but not invoke till later?
var ff = function(a,b) { return a + b; };
var add23 = ff(2,3); // don't invoke yet
add23(); // ok invoke.
i mean, right now i'm doing var add23 = function() { return ff(2,3); };
but the ff func is a curried function, and i just kinda wondered if there was a pretty way. I am using this for effects, so I have a generic function I pre-bind values, so I can call it "toggleSaveButtons" vs "animate(element, startClass, endClass, ..)"
and maybe I should read the doc on R.partial right. I was invoking it wrong :(
heh