These are chat archives for ramda/ramda

30th
Mar 2016
Scott Sauyet
@CrossEye
Mar 30 2016 00:03
Thanks. We're pretty happy with it.
I don't see any fundamental change to your function, although I might break it into smaller pieces, except that, as you say, the function name might not be the best cache key. You might also want to include some JSON-stringified version of the arguments, or some such.
Jigar Gosar
@jigargosar
Mar 30 2016 02:10

Hey people,

var overAppend = R.curry(function (destinationLens, elementLens, dataTree) {
                        return R.over(destinationLens, R.append(R.view(elementLens, dataTree)), dataTree);
                    });

Any way to shorten this, pointer-free?

Scott Sauyet
@CrossEye
Mar 30 2016 02:43
It's hard to imagine a points-free version that would be more readable.
Jigar Gosar
@jigargosar
Mar 30 2016 04:55
@CrossEye fair enough. is there some other style to write this?
decompose it into smaller reusable components?
Raine Revere
@raineorshine
Mar 30 2016 05:22
@jigargosar I appreciate the challenge of making things point-free… even when it makes no sense in terms of readability :)
Jigar Gosar
@jigargosar
Mar 30 2016 05:38

@metaraine thanks, I like to push the boundaries when learning. In past, when I was newly excited and super passionate about an idea, I would apply it everywhere. Now after 15+ years of programming, I mindfully practice the exact same behaviour, since I have realised it’s benifits.

When reality makes its demands, I can swiftly switch to being pragmatic, without feeling sad as I used to; trying very very hard to make things look perfect, ideal. Experiences teaches one to be more pragmatic, of course only if one is willing to listen ;).

But I love the boundries, the ideal world, the perfectness, the perfectly imperfect reality, the freedom to dream, aspire and imagine. And I love driving, folding, warping, bending, streching the real world in that direction. The focus in on the process, that is what I enjoy. That is my hobby, that is my leisure time.

Raine Revere
@raineorshine
Mar 30 2016 05:41
:dancers: :ok_hand:
Stepan Kuzmin
@stepankuzmin
Mar 30 2016 07:02
Hi there! Is there any way to somehow trigger function applying in R.compose flow based on external argument?
Eg.
R.compose(fn3, fn2, fn1) // where extecution of fn2 is based on some rule
Is R.apply(R.ifElse(exp, fn2, R.identity)) ok?
Denys Mikhalenko
@prontiol
Mar 30 2016 07:56
This message was deleted
This message was deleted
This message was deleted
This message was deleted
This message was deleted
Denys Mikhalenko
@prontiol
Mar 30 2016 08:03
R.ifElse(expr, fn2, R.identity)
Scott Christopher
@scott-christopher
Mar 30 2016 08:05
If you find yourself wanting to pass identity as either of the branches to ifElse then when and unless can be useful.
Stepan Kuzmin
@stepankuzmin
Mar 30 2016 08:05
Thanks @prontiol, but R.ifElse returns function, not value
Scott Christopher
@scott-christopher
Mar 30 2016 08:05
R.when
Scott Christopher
@scott-christopher
Mar 30 2016 08:06
R.unless
Denys Mikhalenko
@prontiol
Mar 30 2016 08:06
you do need a function to pass it into R.compose
Stepan Kuzmin
@stepankuzmin
Mar 30 2016 08:06
Whoa, R.when is what i need! Thanks @scott-christopher!
Scott Christopher
@scott-christopher
Mar 30 2016 08:07
:thumbsup:
Denys Mikhalenko
@prontiol
Mar 30 2016 08:07
cool
Stepan Kuzmin
@stepankuzmin
Mar 30 2016 09:03
What is the best way to split list into two lists based on predicate function? R.groupBy?
Raine Virta
@raine
Mar 30 2016 09:04
R.partition
Stepan Kuzmin
@stepankuzmin
Mar 30 2016 09:04
Awesome! Thanks @raine!
Jigar Gosar
@jigargosar
Mar 30 2016 12:29
This message was deleted
hey guys, need code review :) there is something fishy about this code I wrote.
var timeSlotRowCount = Math.round(
                endTime.diff(startTime, "minutes") / 5
            );
            R.times(function (row) {
                return DateTime.formatTime(d.startTime.add(5 * row, "minutes"))
            }, timeSlotRowCount);
it generates an array of time from startime to endtime, at 5min, interval.
I am hoping there is better way to do this; additive step until some condition is met to generate an array.
is there a general way to solve this type of problem. generate an array, from start to end, at certain increment.
Jigar Gosar
@jigargosar
Mar 30 2016 12:37
ok, found it, I think I need to use scan function. let me try!
:( nope scan requires input as an array.
can anyone help?
Is there a general way to solve this type of problem. generate a list, from given startvalue and endvalue, at some increment (increment is determined by the function)
John Michel
@johnmichel
Mar 30 2016 12:44
R.range might help, but it lacks a custom increment function
Jigar Gosar
@jigargosar
Mar 30 2016 12:44
:(
I think I will have to build my own generalization for now.
@johnmichel tx
is there some concept of stream, in R?
hkrutzer
@hkrutzer
Mar 30 2016 12:46

is there a better way of doing

let activeMarkerIds = R.pluck('id', activeMarkers(markers));
return R.filter((m) => R.contains(m.id, activeMarkerIds), richMarkers);

? can I get rid of the arrow function?

Aldwin Vlasblom
@Avaq
Mar 30 2016 12:50
@hkrutzer Whether it's better than the lambda is for you to decide:
const isContainedIn = R.flip(R.contains);
R.filter(R.where({id: isContainedIn(activeMarkerIds)}))
hkrutzer
@hkrutzer
Mar 30 2016 12:53
hm, is there maybe a better way of extracting ID's out of an array of objects, and then filtering another array of objects on those ID's?
I was looking at intersectionWith but the objects do not have the same fields besides the ID
Aldwin Vlasblom
@Avaq
Mar 30 2016 12:59
I think intersectionWith would work for that.
Jakub Korzeniowski
@kujon
Mar 30 2016 12:59
@jigargosar had to do the same yesterday and ended up writing http://goo.gl/xVKTdP. Prolly inefficient though.
Jigar Gosar
@jigargosar
Mar 30 2016 13:00
@kujon :)
Jakub Korzeniowski
@kujon
Mar 30 2016 13:00
it also blows up for non-integers and ints < 1
Jigar Gosar
@jigargosar
Mar 30 2016 13:01
let me come up with a general version since, I am using moment datetime.
hkrutzer
@hkrutzer
Mar 30 2016 13:08
Avaq only if the lists are of equal size it looks like, https://github.com/ramda/ramda/blob/v0.20.1/src/intersectionWith.js
or if one is always larger
Jigar Gosar
@jigargosar
Mar 30 2016 13:12
@kujon basically we need opposite of reduce, a function that expands. and we have takeWhile, all we need is to pass it a transformer, I think. Let me experiment.
Jigar Gosar
@jigargosar
Mar 30 2016 13:20
actually, I don't understand what a transformer function is.
can anyone explain?
ramda documentation is filled with this word.
Jakub Korzeniowski
@kujon
Mar 30 2016 13:23
alternatively you could just work on integers and map(moment) in the end:
// momentToMinutes :: Moment -> Int
const momentToMinutes = m => Math.floor(m.toDate().getTime() / 1000 / 60);

const start = moment();
const end = moment().add(7, 'days');
const interval = 5;
// makeTimeIntervals :: Int -> Int -> Int -> [Moment]
const makeTimeIntervals = compose(map(moment), rangeWithIncrement);

makeTimeIntervals(interval, momentToMinutes(start), momentToMinutes(end));
Jigar Gosar
@jigargosar
Mar 30 2016 13:30
@kujon thanks
but don't you feel that something is really missing here?
something basic.
opposite of reduce.
we need and expand function.
I am going to figure this out.
:)
Jakub Korzeniowski
@kujon
Mar 30 2016 13:33
potentially. I haven't given these solutions much thoughts tbh ^^
Julien Goux
@jgoux
Mar 30 2016 13:33
Does anyone use the "union-type" library here ?
Jakub Korzeniowski
@kujon
Mar 30 2016 13:39
@jigargosar what about:
http://ramdajs.com/docs/#unfold
Stefano Vozza
@svozza
Mar 30 2016 13:50

Is there a general way to solve this type of problem. generate a list, from given startvalue and endvalue, at some increment (increment is determined by the function)

Have looked at R.unfold?

oops, looks like my gitter was a bit behind!
Hardy Jones
@joneshf
Mar 30 2016 14:11
haha, @svozza I was about to suggest the same thing, so I didn't scroll to the bottom either :)
Stefano Vozza
@svozza
Mar 30 2016 14:11
:laughing:
Hardy Jones
@joneshf
Mar 30 2016 14:16
@ram-bot
const end = 30;
const grow = n => n < end && [n, n + 5];
unfold(grow, 0);
ram-bot
@ram-bot
Mar 30 2016 14:16
[ 0, 5, 10, 15, 20, 25 ]
Hardy Jones
@joneshf
Mar 30 2016 14:16
@jigargosar ^
Jigar Gosar
@jigargosar
Mar 30 2016 14:20
@joneshf finally!
i was going nuts.
I checked so many other functions, but missed this one. ;)
@kujon thanks. my window got stuck, wasn't receiving updates.