These are chat archives for ramda/ramda

22nd
Feb 2017
Rafi
@Rafi993
Feb 22 2017 04:15
Hi there. I was wondering what is the Ramdajs equivalent of _.some from lodash
thanks in advance
Brad Compton (he/him)
@Bradcomp
Feb 22 2017 04:45
R.any
Keith Alexander
@kwijibo
Feb 22 2017 07:48
@puffnfresh so you search hoogle, and then google search, eg, foldMapDefault javascript? or look in the ramda docs? and then write it yourself?
(how much of the time do you have to write it yourself?)
Bravi
@Bravilogy
Feb 22 2017 09:57
I can't get enough of functional programming :D
it's so addictive
Keith Alexander
@kwijibo
Feb 22 2017 11:37
maybe :) I dunno, it was just a random example of a function
Galileo Sanchez
@galileopy
Feb 22 2017 13:25
Yesterday was the first time that I wrote a truly reusable sort of component, without thinking too much about it. And it made me wonder about the more lispy languages, since one of the reasons I didn't learn Clojure or Scheme earlier was, that there seemed to be a very small community, and that there weren't that many libraries available as they are in javascript or python, and I remember reading things like, there are no needs to have a library for everything, lisp programmers usually have the ability and the tools necessary to build it all themselves without relying too much on external dependencies. But a language doesn't seem to be enough, what actually makes this possible IMHO is the abstractions that you learn, the more powerful the tools available, the more productive you become, and I wonder now, for how long have these abstractions been existing?
Bravi
@Bravilogy
Feb 22 2017 13:32

@galileopy we are using clojure at my workplace. we use re-agent + re-frame combo for front end and I truly enjoy writing clojure for some unknown reason. recently I discovered this:
https://funcool.github.io/cats/latest/

and we're thinking about re-implementing some stuff in our current codebase using all these abstractions

Galileo Sanchez
@galileopy
Feb 22 2017 13:43
@Bravilogy nice!! This is like learning programming again :)
I mean, I've first learned control structures, and variables and mutation, and then I saw how to accomplish similar results in similar languages, and how to all this languages seemed all the same, with each one having it's own quirks to make stuff work, and functional programming seems to be the same thing, but instead of learning syntax for the same usual concepts, now I'm learning concepts that can be translated to different syntaxes, just like learning what a for loop does and then using them on c, c++, java and the like.
Galileo Sanchez
@galileopy
Feb 22 2017 13:50
After learning fp in javascript, lisp doesn't seem too alien anymore, and I think the same can be said of haskell, but I have not studied haskell that much to be sure of that.
Denis Stoyanov
@xgrommx
Feb 22 2017 13:51
after learning haskell, looks like other languages are really poor :smile:
Michael Zinn
@RedNifre
Feb 22 2017 13:52
If you like Haskell and JS you might find PureScript interesting.
Galileo Sanchez
@galileopy
Feb 22 2017 13:53
@xgrommx do you have any experience with lisp? I am still intrigued by PG saying what he says about lisp. Also, I see you do some mathy stuff from time to time, is that lambda calculus or combinatory logic, and were can I learn that stuff?
Denis Stoyanov
@xgrommx
Feb 22 2017 13:53
I know about purescript/elm/ghcjs/haste/fay :smile:
Michael Zinn
@RedNifre
Feb 22 2017 13:54
what's haste?
Denis Stoyanov
@xgrommx
Feb 22 2017 13:54
@galileopy so, I don't like (...) :smile:
@galileopy https://github.com/xgrommx/awesome-functional-programming#combinators also I need to prepare list of LC (lambda calculus) but anyway LC/CL from logic.
Galileo Sanchez
@galileopy
Feb 22 2017 13:56
Cool!!! thank you very much!
Galileo Sanchez
@galileopy
Feb 22 2017 14:09
:heart_eyes:
Denis Stoyanov
@xgrommx
Feb 22 2017 14:11
also monad for Fn will be
const B1 = B(B)(B);
const MO = B1(W)(B);
const MO1 = B(B(W))(B);

console.log(MO1(x => y => x * y)(x => x * 10)(10));
MO and MO1 is monad bind for Fn
Galileo Sanchez
@galileopy
Feb 22 2017 14:12
So it is combinatoric logic?
Denis Stoyanov
@xgrommx
Feb 22 2017 14:12
yes
with SK basis
also exists one basic
like X
Galileo Sanchez
@galileopy
Feb 22 2017 14:13
SK?
Denis Stoyanov
@xgrommx
Feb 22 2017 14:14
yes, this is axiomatic basis (became from logic)
Galileo Sanchez
@galileopy
Feb 22 2017 14:16
This stuff makes me wonder if that is what I'll find in Let Over Lambda, have you read that one?
Denis Stoyanov
@xgrommx
Feb 22 2017 14:17
about lambda calculus?
for combinators we have only one metaoperation like application but for lambda calculus we have 2 metaoperations like application and abstraction
Galileo Sanchez
@galileopy
Feb 22 2017 14:19
is a lisp book, it is on my to-read list as soon as I feel ready for it
Denis Stoyanov
@xgrommx
Feb 22 2017 14:19
CL and LC has Turing completeness
Bravi
@Bravilogy
Feb 22 2017 14:42
is there a good tutorial on hindley milner's type system?
Denis Stoyanov
@xgrommx
Feb 22 2017 14:43
and system-f
Brad Compton (he/him)
@Bradcomp
Feb 22 2017 16:00
@Bravilogy Not exactly HM, but there's an explanation of Ramda's type sigs in the wiki
Bravi
@Bravilogy
Feb 22 2017 16:01
@Bradcomp amazing, thanks!
Bravi
@Bravilogy
Feb 22 2017 16:18
@Bradcomp ok I'm following that guide and trying to write these signatures for a few functions I've written here. And I can't decide whether i'm right or wrong here :D
// ((a -> Boolean), [a]) -> Boolean
const any = (pred, xs) =>
    xs.reduce((prev, next) => pred(next) ? true : prev, false);

any(x => x > 3, [2, 3, 4]) //=> true
Brad Compton (he/him)
@Bradcomp
Feb 22 2017 16:19
That looks right to me
R.any
Bravi
@Bravilogy
Feb 22 2017 16:19
hmm
Brad Compton (he/him)
@Bradcomp
Feb 22 2017 16:19
You can see the Ramda version is basically the same, but without the parens
Bravi
@Bravilogy
Feb 22 2017 16:19
oh that's because of currying
Brad Compton (he/him)
@Bradcomp
Feb 22 2017 16:19
That's because the Ramda version is curried
Bravi
@Bravilogy
Feb 22 2017 16:19
yayy
:D
I'm happy now
thanks!
R.map
Bravi
@Bravilogy
Feb 22 2017 16:24
R.reduce
Bravi
@Bravilogy
Feb 22 2017 16:25
hah that was easy :D
Brad Compton (he/him)
@Bradcomp
Feb 22 2017 17:05
R.pathEq
Brad Compton (he/him)
@Bradcomp
Feb 22 2017 17:07
R.propEq
Vincent Orr
@Cmdv
Feb 22 2017 17:14
I'm trying to check an array of numbers for duplicates where I use difference and that works great by removing the duplicates, but what I would like to do is if the number isn't a duplicate append it to the array :
const a = [1,2,3,4,5]
const b = 5
const c = 6
a <> b == [1,2,3,4]
a <> c == [1,2,3,4,5,6]
Galileo Sanchez
@galileopy
Feb 22 2017 17:24
@ram-bot
const a = [1,2,3];
const appendUnique = ifElse(R.complement(R.contains(R.__, a)), R.append(R.__, a), R.always(a));
appendUnique(4);
Vincent Orr
@Cmdv
Feb 22 2017 17:33
@galileopy thank you but it doesn't remove if duplicate
Denis Stoyanov
@xgrommx
Feb 22 2017 17:44
[...new Set(arr)]
Vincent Orr
@Cmdv
Feb 22 2017 17:47
I'm close:
ifElse(contains, difference, concat)(a, b)
just contains need to have it's inputs flipped
Bravi
@Bravilogy
Feb 22 2017 17:47
R.flip ?
Vincent Orr
@Cmdv
Feb 22 2017 17:48
I tried putting it like ifElse(flip(contains), difference, concat)(a, b)
maybe I need to chain the flip
Gabe Johnson
@gabejohnson
Feb 22 2017 17:48
@xgrommx simplest solution
Bravi
@Bravilogy
Feb 22 2017 17:49
I'll copy your code to repl now
Vincent Orr
@Cmdv
Feb 22 2017 17:49
of course totally forgot about Set :joy: thanks @xgrommx
Bravi
@Bravilogy
Feb 22 2017 17:52
@xgrommx thanks awesome!
Denis Stoyanov
@xgrommx
Feb 22 2017 18:01
np =)
also via groupBy
compose(keys, groupBy(identity))([1,2,3,1,2,3,4])
Vincent Orr
@Cmdv
Feb 22 2017 18:36
:+1:
Denis Stoyanov
@xgrommx
Feb 22 2017 18:48
Brian McKenna
@puffnfresh
Feb 22 2017 22:30
@kwijibo sometimes I search GitHub for the name
but I often have to write a function myself
Keith Alexander
@kwijibo
Feb 22 2017 22:31
:+1:
I guess you can search pursuit by type sig, right? and eventually get at a javascript function, somehow