These are chat archives for ramda/ramda

13th
Sep 2015
hemanth.hm
@hemanth
Sep 13 2015 16:40
@raine I'm planning to extend repl.context of ramda-repl module with ramda-fantasy what say?
Raine Virta
@raine
Sep 13 2015 17:15
hemanth: makes sense
Tobias Pflug
@gilligan
Sep 13 2015 17:29
@joneshf trying to get a hang on jsverify
@joneshf don't really grok arbitrary/combinator functions
need to generate objects with random key/value pairs where values are either strings or array of strings
and i don't understand how to do that
@joneshf got any experience with jsverify ?
Scott Christopher
@scott-christopher
Sep 13 2015 20:58
@gilligan I haven't tried it, by I think you should be able to create an arb of that with jsc.dict(jsc.sum([jsc.string, jsc.array(jsc.string)]))
Scott Christopher
@scott-christopher
Sep 13 2015 22:41
Just tried this out and it looks like you'll want to use oneof instead of sum, otherwise you'll have to fold over it to get the value out.
jsc.dict(jsc.oneof(jsc.string, jsc.array(jsc.string)))
Denis Stoyanov
@xgrommx
Sep 13 2015 22:49
Hi all! Exist some approach for transformation arguments to array? I have found only this approach http://bit.ly/1KgS5C4
Scott Christopher
@scott-christopher
Sep 13 2015 22:51
@xgrommx There aren't any specific functions for that in Ramda. I have always just done as you have with your example and used R.unapply(R.identity)
Denis Stoyanov
@xgrommx
Sep 13 2015 22:52
Strange that no method like a R.toArray
Scott Christopher
@scott-christopher
Sep 13 2015 23:00
A number of functions like this that don't quite fit the core library are captured in the Cookbook: https://github.com/ramda/ramda/wiki/Cookbook#create-a-list-function
Denis Stoyanov
@xgrommx
Sep 13 2015 23:22

Hi all again =) I have this code:

this.scan((acc, next) => R.ifElse(R.both(R.lte(left), R.gte(right)), () => acc.concat(next).sort(), () => acc)(next), [])

But I would like don't use callback and use something like that:

this.scan(R.curryN(2, R.compose(R.nthArg(0), R.ifElse(R.both(R.lte(left), R.gte(right)), R.nthArg(1).concat(R.nthArg(0)).sort(), R.nthArg(1) /*acc*/))), [])

How can I do it?

This is more simplify but It isn't what I want with Ramda)
Rx.Observable.prototype.bufferWithBounds = function(left, right) {
  return Rx.Observable.create(observer =>
    this.scan((acc, next) => R.ifElse(R.both(R.lte(left), R.gte(right)), R.always(acc.concat(next).sort()), R.always(acc))(next), []).distinct().skip(1)
        .subscribe(
          ::observer.onNext, 
          ::observer.onError, 
          ::observer.onCompleted)
  );
};
Scott Christopher
@scott-christopher
Sep 13 2015 23:59
@xgrommx The only suggestion I could make would be to convert your concat then sort method calls to something like the following:
this.scan((acc, next) =>
    R.ifElse(R.both(R.lte(left), R.gte(right)),
             R.compose(R.sortBy(R.identity), R.concat(acc)),
             R.always(acc))(next), [])