These are chat archives for ramda/ramda

28th
Apr 2016
James Forbes
@JAForbes
Apr 28 2016 05:52

Hey what is a good way to intersperse n times.

e.g. I've got [[1,1], [1,1], [1,1]] and I want [[1,1], [0,0], [0,0], [0,0], [1,1],[0,0],[0,0],[0,0], [1,1]]

Ivan Demchenko
@raqystyle
Apr 28 2016 11:11

Looks like, there's no way to apply the resulting function from composition.

const vector = compose(fromPairs, zip)
vector(['a', 'b', 'c'], [1, 2, 3])
vector(['a', 'b', 'c'])([1, 2, 3]) // wrong

I understand why. But is it a correct behavior?

Raine Virta
@raine
Apr 28 2016 11:32
@raqystyle yes because compose doesn't return curried functions
Scott Sauyet
@CrossEye
Apr 28 2016 11:33
@raqystyle: There were long discussions about this. You can see some of them in #1318 and other issues linked from there.
Ivan Demchenko
@raqystyle
Apr 28 2016 11:34
@raine yes, makes sense.
@CrossEye thank you!
Tobias Pflug
@gilligan
Apr 28 2016 11:38
@CrossEye you changed your avatar -- how confusing ;--}
Scott Sauyet
@CrossEye
Apr 28 2016 11:39
Yeah, first time in many years. ... maybe I'll do it again next week. :smile:
James Forbes
@JAForbes
Apr 28 2016 11:44
@CrossEye I like the avatar :thumbsup:
Tobias Pflug
@gilligan
Apr 28 2016 11:44
hehe
Vladimir Starkov
@iamstarkov
Apr 28 2016 14:18
can anybody review some of my fp packages i built with ramda?
Brad Compton (he/him)
@Bradcomp
Apr 28 2016 14:19
@6ewis Sorry for the delay. The object diffing code is dense, but it does a lot. It gives you separate objects for what stayed the same, what changed, and what just exists on one side and the other. Do you just want an object with the properties that are only on one side or the other, but not both?
Lewis
@6ewis
Apr 28 2016 14:20
@Bradcomp I was just curious , it's just pure intellectual challenge - I was trying to do this: http://goo.gl/LWwMi8
Julien Goux
@jgoux
Apr 28 2016 14:40
@davidchambers For sanctuary-js/sanctuary-def#60, I'm not sure what I have in mind xD
Basically I'd like to switch to sanctuary-def (using tcomb right now), and union is a missing part that I'm using a lot with tcomb
There is a match function to switch on union type, but I'm not sure about how I would design a union type internally in the context of sanctuary-def
Having some sort of array of @@type maybe
Scott Sauyet
@CrossEye
Apr 28 2016 14:57
@iamstarkov: feel free to pay some links. If I can, I'll try to take a look this evening.
Brad Compton (he/him)
@Bradcomp
Apr 28 2016 15:29
@6ewis I won't give it away if it's a learning exercise, but there are significant simplifications that can be made if you only want to know what properties have been added or removed. The main insight is that the keys of the object can be represented as a set (a list with no duplicates), and so you can use the set operations on them to get the information you need. Ramda has most of the set operations available, and you can use the With variants to operate on the keys if you convert the object toPairs.
R.differenceWith
Lewis
@6ewis
Apr 28 2016 15:57
@Bradcomp I'll look into that when i have some time. i put it in my backlog of things to do - thanks
Tim Navrotskyy
@dypsilon
Apr 28 2016 17:32
Hi everyone, is there a channel or a mailing list somewhere to discuss functional programming in javascript in general?
This channel is great with lots of smart people, but general FP questions are probably offtopic here...
Chet Harrison
@ChetHarrison
Apr 28 2016 17:33
this is probably as good as it gets
Scott Sauyet
@CrossEye
Apr 28 2016 17:35
functionalprogramming.slack.com
There is a js channel. Sometimes active, sometimes dead. But we're pretty happy to hear general-purpose questions here.
Tim Navrotskyy
@dypsilon
Apr 28 2016 17:37
Oh, in this case I'd just rather stay here.
Scott Sauyet
@CrossEye
Apr 28 2016 17:39
If they're related to to Ramda, Sanctuary, or Fantasy-land, they're absolutely on topic. If they're about general topics, we're happy to discuss. Other libraries are fine too. But lets not do Library A versus Library B.
Stefano Vozza
@svozza
Apr 28 2016 17:45

but general FP questions are probably offtopic here...

That couldn't be further from the truth, the amount of general FP stuff I've learnt from this room is amazing

Tobias Pflug
@gilligan
Apr 28 2016 17:49
@svozza I agree ;)
Tobias Pflug
@gilligan
Apr 28 2016 18:24
@CrossEye hm.. i suppose the whole "giving fantasyland a name that sounds less like a joke" discussion never went anywhere did it?
Brad Compton (he/him)
@Bradcomp
Apr 28 2016 19:35
Speaking for myself I love the name
John-David Dalton
@jdalton
Apr 28 2016 19:37
Is there some official spec standards body for it or just some folks org?
Lewis
@6ewis
Apr 28 2016 19:54

@Bradcomp is it ok ? or is there a better way

const data =  [
    {
      "client_number": "00001",
      "client_name": "voila Communications Ltd.",
      "address1": "Ben votrant",
      "address2": "voila Communications",

    },
{
      "client_number": "00002",
      "client_name": "sinc Limited-in Liquidation",
      "address1": "vertravt Bank Trust",
      "address2": "Corporate (v) Limited",

    },
];

 let value = "sinc";
 let inputValue = value.trim().toLowerCase();
 let inputLength = inputValue.length;

// const sameClient = (client) => 
//   client.toLowerCase().slice(0, inputLength) === inputValue;

//plain JS version
// const getSuggestions = (value) => {
//    return inputLength === 0 ? [] : data.filter(billingClient =>
//      sameClient( billingClient.client_number) ||
//      sameClient( billingClient.client_name)
//    );
// }

 const isTheSame = (arg) => arg.toLowerCase().slice(0, inputLength) === inputValue;
 const sameName = (client) => isTheSame(client.client_name);
 const sameNumber = (client) => isTheSame(client.client_number);

//ramda version
 const getSuggestions = (value) => {
    return inputLength === 0 ? [] : R.filter(R.either(sameName, sameNumber), data);
 } 

getSuggestions("sinc");

http://goo.gl/2tGYEe

Brad Compton (he/him)
@Bradcomp
Apr 28 2016 20:12
@6ewis try changing "sinc" in the last line to something else, and it won't change the output of your function (same with the vanilla one). The value isn't being used to filter the results.
Lewis
@6ewis
Apr 28 2016 20:36
@Bradcomp I dont have anymore brain cell to figure out what i did wrong on the link above but here's a working version http://goo.gl/Y5YQ0A in plain js
Scott Sauyet
@CrossEye
Apr 28 2016 21:02
@gilligan: No, that didn't go anywhere, nor did anyone really expect it to. But at least people there have heard the objection.
@jdalton: just some folks, the same way Promises started. In fact, it started as an explicit reaction to some of the work in Promises A+.
Even the name came from adopting for themselves a disparagement from someone in a Promises A+ issue.
John-David Dalton
@jdalton
Apr 28 2016 21:07
Spec work and pushing it is an uphill fight.
Scott Sauyet
@CrossEye
Apr 28 2016 21:08
Absolutely.
Scott Sauyet
@CrossEye
Apr 28 2016 21:14
This is an odd one though. It's a spec no one is really trying to push anywhere else, because it's more of a contract between two groups of developers.
Tim Navrotskyy
@dypsilon
Apr 28 2016 21:37
Do you think it's important to write point-free-only-code?
Brad Compton (he/him)
@Bradcomp
Apr 28 2016 21:54
@dypsilon I think point free can be helpful, but I definitely don't use it all the time.
Lewis
@6ewis
Apr 28 2016 22:47
@Bradcomp thanks . I prefer the plain js solution so much better http://goo.gl/Y5YQ0A
Stefano Vozza
@svozza
Apr 28 2016 23:11
that's just because you're close to the problem. looking at your version at first glance i have no clue what it's doing, which is exactly how a developer coming to it to maintain it would feel initially. @Bradcomp 's version gives me a lot more information from the get go
This message was deleted