These are chat archives for ramda/ramda

27th
Aug 2016
Scott Sauyet
@CrossEye
Aug 27 2016 00:18
I don't know if I'd be interested in a mapAll. But I certainly would not want to change map in this manner.
What @xgrommx was pointing out is that map has the nice signature, Functor f => (a -> b) -> f a -> f b. It works for any functor, including an array. Of course mostly the implementation is up to you. But if you have a FantasyLand-compatible Functor, Ramda's map will work with it. And that's all it does.
Trying to add additional behavior loses too much of the simplicity that Ramda strives for.
Scott Sauyet
@CrossEye
Aug 27 2016 00:24
I probably would prefer to extend zipWith this way, if anything.
Churchill Lee
@FeliciousX
Aug 27 2016 04:55
so im trying to practice more functional programming
and i plan to make a 2048 clone
but with FP
so now what would be the FP way to transform an array [2,2,2,2] to [4,4,0,0]?
first i try writing it the imperative way, and i manage to merge [0,2,0,2] to [4,0,0,0] etc.. but when it's
[2,2,2,2] it will become [8,0,0,0]
btw my data structure is a 2D array
following the board
const board = map( row =>
  map( col => ( row + col === 5 ) ? 2 : 0,
    range(0, 4)
  ),
  range(0, 4)
);
James Forbes
@JAForbes
Aug 27 2016 06:04

@FeliciousX 2048 was a clone, of threes, which was designed over 14 months by two game devs who get basically 0 credit.

Before you clone it, maybe think if you should, and read this first http://asherv.com/threes/threemails/

Tycho Grouwstra
@tycho01
Aug 27 2016 11:36
In Lodash I would use _.size to check if for 'truthy' values in such a way as to consider empty arrays/objects false. I noticed R.path is pickier, only returning results on array inputs. I wonder, is there a nice and terse way to do this in Ramda?
Raine Virta
@raine
Aug 27 2016 11:38
R.isEmpty
Tycho Grouwstra
@tycho01
Aug 27 2016 11:49
Thanks!
Churchill Lee
@FeliciousX
Aug 27 2016 11:59
@JAForbes I am aware of it. thanks for the article :) I'm just doing it to learn
James Forbes
@JAForbes
Aug 27 2016 13:07
@FeliciousX Fair enough, but If you are aware of it, why did you call it 2048?
Raine Virta
@raine
Aug 27 2016 13:12
more commonly known
James Forbes
@JAForbes
Aug 27 2016 13:16
@raine and why is it more commonly known?
Raine Virta
@raine
Aug 27 2016 13:17
it went viral
James Forbes
@JAForbes
Aug 27 2016 13:18
And why did it go viral?
Raine Virta
@raine
Aug 27 2016 13:18
luck?
why do some products succeed and others fail
James Forbes
@JAForbes
Aug 27 2016 13:21
Because they released the clone before the actual game was released. Its not luck at all.
Raine Virta
@raine
Aug 27 2016 13:22
there's no guarantee threes would have been a success even if 2048 didn't came to be
James Forbes
@JAForbes
Aug 27 2016 13:26

If you knew anything about the mobile game market, you wouldn't say that. There are so many examples of this happening.

Ridiculous Fishing (another game made by 1 of the creators of threes) had almost the exact same thing happen to them. The same story over and over again. If you have a new mechanic, and you get to market first, you win.

Churchill Lee
@FeliciousX
Aug 27 2016 14:35
i said it coz it is more commonly known. sorry to trigger u
im here to learn not to debate :)
Alexandre BODIN
@alexandrebodin
Aug 27 2016 17:16

Hi guys !

Here I'm using a Future Monad.
I'm look for something to be able to pass along extra info when chaining like so:

fn1(param)
.chain(fn1Res => fn2(fn1Res))
.chain((fn1Res, fn2Res) => {
    fn3(fn1Res);
    // I want to be able to wait for fn2 to finish but execute fn3 with fn1 output
});

There are many alternatives using variables but I want to keep my control-flow in boxes