by

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 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
Rodrigo Álvarez
@Papipo
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
@Papipo
@amirbr :point_up:
Brad Compton (he/him)
@Bradcomp

@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
@mweichert
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)
@Bradcomp
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?
amir
@amirbr
@Bradcomp @Papipo thank you so much you are amazing :)
Ilya Sevostyanov
@RUVATA

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


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

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

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
@devmao
how to write this :
const res = x => fn1(x) || fn2(x)
// in
const resFn = or(f1, f2)
const res = resFn(x)
Ben Briggs
@ben-eb
@devmao Check out R.either
glarget
@glarget
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
glarget
@glarget
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
glarget
@glarget
const arr = [undefined, undefined] !R.includes('Toute la France', ...arr)
that one doesn't work
Nikolaus Fedurko
@B1Z0N

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 https://github.com/ramda/ramda/blob/master/source/internal/_arity.js :

default: throw new Error('First argument to _arity must be a non-negative integer no greater than ten');
John Hartnup
@ukslim
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 https://en.wikipedia.org/wiki/Hilbert%27s_paradox_of_the_Grand_Hotel
#!/bin/BasH
@bas080
@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
@devmao
project.crews.forEach(c => c.calendar.forEach(w => { acc.Workweek[project.calendarWorkweekById[w.calendarWorkweekId].name] = true; })); better?
Brad Compton (he/him)
@Bradcomp

: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)
@Bradcomp
@/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
Zolboobayar
@zolbooo
Hi guys! I've created simple interactive tutorial based on Randy Coulman's blog: Thinking in Ramda. Try it out: https://github.com/zolbooo/ramda-learning
Tips and advices are welcome 😉
#!/bin/BasH
@bas080
@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)
Zolboobayar
@zolbooo
Got it, thank you for your feedback!
You should edit code to pass all tests in sections.
Aadi Deshpande
@cilquirm

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
@kapooostin
@cilquirm you could use chain for this:
// getProposedLogin :: Object -> String
const getProposedLogin = o(
  join( '' ),
  props( [ 'firstName', 'lastName', 'age' ] )
)

// addProposedLogin :: Object -> Object
const addProposedLogin = chain(
  assoc('proposedLogin'),
  getDerivedProperty
);

const pipeline = pipe(
  …,
   addProposedLogin
);
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
@kapooostin
ap gives you ap (f, g) (a) = f (a) (g (a)) and chainchain (f, g) (a) = f (g (a)) (a)
Vladimir Kapustin
@kapooostin
:point_up: addPropertyLogin should be:
// addProposedLogin :: Object -> Object
const addProposedLogin = chain(
  assoc('proposedLogin'),
  getProposedLogin
);
Johnny Hauser
@m59peacemaker
I feel like I mostly understand transducers, but there's one case that blew up my brain and I'm having trouble getting through it... with the idea of transducing a reactive type, like an frp event/stream kind of thing - it's pretty straightforward that you start with a stream, each value from it goes through the pipeline, and there's a builder on the end pushing the transformed value into the resulting stream. I don't think I have an issue with my mental model here. But when I approach the idea of a fold on an event/stream, I am lost.
eventStream.fold((acc, v) => [ ...acc, v ], [])
what would that mean with transducers?
Johnny Hauser
@m59peacemaker
I think it would be like [ 1, 2, 3 ] to [ [ 1 ], [ 1, 2 ], [ 1, 2, 3 ] ]
John Hartnup
@ukslim
@kapooostin @cilquirm , this is great. I've got a function I use often that isn't written in Ramda, but I use from Ramda a lot:
```
const assocDerived = (name, f, obj) => ({
  ...obj,
  [name]: f(obj),
})
(Wrap it in curry() ... I left it off for brevity)
But I may start using chain instead.
Aadi Deshpande
@cilquirm
thank you so much @kapooostin. this completely opened my :eyes:
Johnny Hauser
@m59peacemaker
I came across the statement 'transducers are perverse lenses', but I don't understand anything said on that topic, of which there is little. Transducers can be used on push-based reactive types. Can lenses be used for such things instead?