Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • Jan 31 2019 22:17
    CrossEye commented #2779
  • Jan 31 2019 21:04
    ArturAralin commented #2779
  • Jan 31 2019 20:08
    CrossEye commented #2779
  • Jan 31 2019 18:56
    buzzdecafe commented #2631
  • Jan 31 2019 18:09
    ArturAralin commented #2779
  • Jan 31 2019 16:18
    CrossEye commented #2779
  • Jan 31 2019 16:10
    CrossEye commented #2631
  • Jan 31 2019 16:06
    CrossEye commented #2777
  • Jan 31 2019 14:44
    ArturAralin opened #2779
  • Jan 31 2019 07:39
    inferusvv commented #2631
  • Jan 31 2019 03:07
    sespinozj commented #2771
  • Jan 31 2019 02:33
    machad0 commented #2771
  • Jan 31 2019 02:26
    JeffreyChan commented #2777
  • Jan 30 2019 14:30
    CrossEye closed #2777
  • Jan 30 2019 12:13
    vanyadymousky updated the wiki
  • Jan 30 2019 01:42
    JeffreyChan commented #2777
  • Jan 29 2019 21:06
    vanyadymousky updated the wiki
  • Jan 29 2019 16:28
    CrossEye commented #2777
  • Jan 29 2019 15:50
    mbostock commented #2772
  • Jan 29 2019 15:48
    CrossEye commented #2772
Aditya Kolnati
const pickResult = R.pick(['result']);
const replaceSlash = R.replace('/\\/g', 'd', R.__)
how do i accomplish this?
i pass this const jsonStr = '{"result":true, "count":42}'; to compose
Brad Compton (he/him)
{ "RESULT": TRUE } this isn't a valid JS object, and that may be part of the issue. do you mean { "RESULT": "TRUE" }?
Aditya Kolnati
ah that was the issue....i was being an idiot..Thanks a lot
Brad Compton (he/him)
:bowtie: Happy to help!
Brad Compton (he/him)
const isEven = item => item % 2 === 0;

const fn = (array) => R.cond([
  [R.equals(0), R.always(R.filter(isEven, array))],
  [R.equals(100), R.always('water boils at 100°C')],
  [R.T, () => 'I want access to the array ' + array + '°C']

There is the simple fix, but it's worth asking if you are solving a real problem here, or just messing with stuff. If I saw something like that during code review I would ask why we were using cond if we always know what the condition we are passing in is (in this case, 0)
@Bradcomp Thank you so much :), I just create a simple example to illustrate my idea. but my question is why I need to use the always function?
Rodrigo Álvarez

From cond documentation:

Returns a function, fn, which encapsulates if/else, if/else, ... logic. R.cond takes a list of [predicate, transformer] pairs. All of the arguments to fn are applied to each of the predicates in turn until one returns a "truthy" value, at which point fn returns the result of applying its arguments to the corresponding transformer. If none of the predicates matches, fn returns undefined.

Bold is mine
it expects functions
I guess R.always can accept any number of arguments and won't complain
so, the argument you pass at the end (0, 100, whatever) is used to call the transformers
and in this case, the transformers do nothing except return R.filter(isEven, array) or 'water boils at 100°C'
Rodrigo Álvarez
@amirbr :point_up:
Brad Compton (he/him)

@amirbr Always is used basically to turn a value into a function to return that value.

R.filter(isEven, array) is evaluated at the time the function fn invoved, returning an Array. Then, after that, 0 is passed into R.cond([...]) at which point it starts checking the conditions.

R.equals(0)(0) is then evaluated, and returns true. As a result, the second item in the pair, R.filter(isEven, array), now evaluated to [2, 4], is retrieved as the function to invoke.

At that point, cond will try to call that function, actually an array, and return the error you experienced.

But this is where I might ask why you are using cond in this way. It's best case is to allow for lazy execution of the branches. In the general case if you pass in a function it will only be evaluated if its guard returns true. By pre-filltering the Array and wrapping the result in Always you force the function to be run every time fn is called regardless of whether the condition holds.
Michael Weichert
Hey all. I was just wondering if anyone has thoughts about when you use Fluture and when to use something like Highland? Both can be used instead of promises, and provide the ability to map/filter/reduce, etc.
Highland, like Fluture, both implement static land compatible methods as well.
Brad Compton (he/him)
I think Highland is a streaming project mainly though right? I haven't heard much about it for the last few years, is t still used / maintained?
@Bradcomp @Papipo thank you so much you are amazing :)
Ilya Sevostyanov

how i can replace neededAlternativeByRamda function by native Ramda function call or combination of calls ?

const neededAlternativeByRamda = (args, func) => arg => func( => (a === R.__ ? arg : a)))

// example of IRL usage
      const newEditorState = R.pipe(
        neededAlternativeByRamda([editorState, R.__, 'change-block-data'], EditorState.push),

I need this for convenient inclusion in the pipe, for use argument that descent on this pipe to functions that have more wide signature that only one argument, and target argument will be placed in arbitrary order in total arguments (replaces R.__ from array of arguments that defined at call)
I think this is good idea and will look good

Maurizio Pucci
how to write this :
const res = x => fn1(x) || fn2(x)
// in
const resFn = or(f1, f2)
const res = resFn(x)
Ben Briggs
@devmao Check out R.either
Hello, I've a problem in ramda and need. your help please
(2) [Array(2), Array(2)]
0: (2) ["["Bmw"]", "["Fiat"]"]
1: (2) ["{"locations":[{"label":"Toute la France"}]}", "{}"]
length: 2
__proto__: Array(0)
I have an array composed of two arrays and i would like to filter the data to only get the item which not contains the word "Toute la France"
What I would like for that exemple is to filter only the first item
I tried includes method but on another cases, I can have an array with undefined values and Includes throws an error ===> canno't find indexOf undefined
const arr = [undefined, undefined] !R.includes('Toute la France', ...arr)
that one doesn't work
Nikolaus Fedurko

Hello, it may be foolish question, but what are the reason of making _arity and, consequently, _curryN accept functions that accept only up to 10 args?

From :

default: throw new Error('First argument to _arity must be a non-negative integer no greater than ten');
John Hartnup
I would guess that JS doesn't give you a way to programatically create a function with an arbitrary number of parameters. Hence they've had to hard-code an implementation of every option from 0 params to 10. I guess they thought "10 should be enough for anyone".
Of course, they could add a line for 11 params, but then you'd be asking why not 12. For some reason I'm reminded of
@raine, I can give you some big files privately. I can't and won't post them as they contain personal preference information.
Maurizio Pucci
project.crews.forEach(c => c.calendar.forEach(w => { acc.Workweek[project.calendarWorkweekById[w.calendarWorkweekId].name] = true; })); better?
Brad Compton (he/him)

:point_up: In some environments you can't create a function with an arbitrary set of parameters. There have been discussions on this before. I will see if I can pull them up.

I think we can revisit this in the future though.

Brad Compton (he/him)
@/all If you are interested in discussing the direction of Ramda with respect to type checking and error messages, please chime in over on this issue: ramda/ramda#2998
Hi guys! I've created simple interactive tutorial based on Randy Coulman's blog: Thinking in Ramda. Try it out:
Tips and advices are welcome 😉
@zolbooo, you are giving instructions to start npm install; npm start. I would also give some information on what the learning format looks like. What people can expect when taking the lesson.
Also, I'm getting the following error:
1:11:03 AM - Found 0 errors. Watching for file changes.
-- Getting started --

⛔️ Test "map: double array" was not passed
TypeError: doubleArray is not a function
    at Object.test (/home/women/projects/ramda-learning/prod/getting_started.js:18:24)
Got it, thank you for your feedback!
You should edit code to pass all tests in sections.
Aadi Deshpande

hi, i’m trying to figure out the best way to tackle this:
i have an object
{ firstName: 'Joe', lastName: 'Schmoe', age: 25, weight: 160 }
that I need to add another property to which combines a few properties into a new property and then adds that to the resulting object.
this is the last chain of a pipe:
pipe(… , <my method>)
The best way I’ve come up with so far is to use converge with assoc and identity:
pipe(… , converge( assoc('proposedLogin'), [ (s) => `${s.firstName}${s.lastName}${s.age}`, identity ] )

but i get the sense that there’s a better way that I’m not aware of

Vladimir Kapustin
@cilquirm you could use chain for this:
// getProposedLogin :: Object -> String
const getProposedLogin = o(
  join( '' ),
  props( [ 'firstName', 'lastName', 'age' ] )

// addProposedLogin :: Object -> Object
const addProposedLogin = chain(

const pipeline = pipe(
ap and chain take up nicely the cases seemingly meant for converge, where there are just two functions and one of them is identity.
Vladimir Kapustin
ap gives you ap (f, g) (a) = f (a) (g (a)) and chainchain (f, g) (a) = f (g (a)) (a)