These are chat archives for ramda/ramda

18th
Mar 2017
Ryan Stegmann
@rstegg
Mar 18 2017 02:27
ramda/ramda#632
Vijay
@vijaytv
Mar 18 2017 02:49
If I have an array with positive integer values interspersed with zeroes, how can I split this array into an array of arrays where zero is the seperator. For e.g [2,3,4,0,3,4,0,2] should be split into [[2,3,4],[3,4],2]
that should be [[2,3,4],[3,4],2]
Brad Compton (he/him)
@Bradcomp
Mar 18 2017 02:51
@ram-bot
compose(map(tail), splitWhen(equals(0)))([2,3,4,0,3,4,0,2] )
ram-bot
@ram-bot
Mar 18 2017 02:51
[ [ 3, 4 ], [ 3, 4, 0, 2 ] ]
Brad Compton (he/him)
@Bradcomp
Mar 18 2017 02:51
hrm, not quite
Markus Pfundstein
@MarkusPfundstein
Mar 18 2017 09:45
is there way to always enable ’tidy’ in ramda/repl ?
Stephan Meijer
@smeijer
Mar 18 2017 09:45
As in permanently. That would be so awesome.
James Forbes
@JAForbes
Mar 18 2017 11:14
What's tidy?
Markus Pfundstein
@MarkusPfundstein
Mar 18 2017 11:20
on the right, yu can enable pretty print output of objects when clicking on tidy. but its reset everytime you change your code
James Forbes
@JAForbes
Mar 18 2017 11:20
ah ok
what's the behaviour now?
Markus Pfundstein
@MarkusPfundstein
Mar 18 2017 14:27
if the last line outputs an object than its displayed on only one line on the right. If i click tidy, it gets expanded and formatted (like JSON.stringify(o, null, 2))
if i change code, it gets reevaluated, but the tidy option also gets disabled and its one line again
i deal with massive objects, so it would be cool if tidy could stay on
Jonathan Rajavuori
@jrajav
Mar 18 2017 15:53
Hi! I've heard that Ramda can provide some structural sharing, and could be used to replace functions of Immutable.js in some ways. I've been looking for resources that explain this a little more and am coming up dry. I'm also not sure about the role of lenses - whether they are necessary for that or what other benefits they might have for passing state down into a component tree
Can anyone guide me to some good reading on all this?
Jonathan Rajavuori
@jrajav
Mar 18 2017 16:00
Mainly I'm wondering how to deal with Ramda to enable shouldComponentUpdate checks (i.e. === has value equality) over deeply nested objects and lists
Drew
@dtipson
Mar 18 2017 21:18
Imo, if you mostly use FP and then you don't really need to immutable at all unless you just don't trust your coworkers (though you could just lint for methods that mutate things as an alternative)
Structural sharing is just a possible optimization for creating new objects from old ones
Drew
@dtipson
Mar 18 2017 21:24
shouldComponentUpdate can work off x!==x plus an x.alt(x) logic, where the latter if your logical knowledge of what types should be considered equal
Daniel Skelton
@dskelton-r7
Mar 18 2017 22:42
@vijaytv
const arr = [0,1,2,0,40,50,0,5,50,2,0,100,107,11,0,12,4,0,200,123,0];
const notEmpty = compose(not, isEmpty);
const _parseInt = (x) => parseInt(x, 10)
const part = compose(map(_parseInt), filter(notEmpty), split(','));

compose( map(part)
       , filter(notEmpty)
       , split(',0')
       , concat(',')
       , (x) => x.toString())(arr)
kinda hacky though
ram-bot
@ram-bot
Mar 18 2017 22:43
[ [ 1, 2 ],
  [ 40, 50 ],
  [ 5, 50, 2 ],
  [ 100, 107, 11 ],
  [ 12, 4 ],
  [ 200, 123 ] ]