These are chat archives for ramda/ramda

9th
Dec 2017
Vesa Karvonen
@polytypic
Dec 09 2017 00:04
@xgrommx Hmm... It seems that a couple of the libraries listed here do not include the description from their repositories. What might be causing that?
Denis Stoyanov
@xgrommx
Dec 09 2017 00:06
@polytypic PR welcome!)
Vesa Karvonen
@polytypic
Dec 09 2017 00:07
Ok. I assumed the descriptions would be fetched by some script.
Denis Stoyanov
@xgrommx
Dec 09 2017 00:07
no) only manually
pentatronix
@pentatronix
Dec 09 2017 07:10
Is there some way to do the same thing as lodash mapKeys in ramda? https://lodash.com/docs/4.17.4#mapKeys
Denis Stoyanov
@xgrommx
Dec 09 2017 12:25
@pentatronix compose(fromPairs, map(([k, v] => ...), toPairs)
dididi
@dfdgsdfg
Dec 09 2017 12:31
Hello, everyone! Is there any hint for more good way?
const getRank = jq => {
  const fromAlt = _.compose(
    _.trim(),
    _.head(),
    _.match(/[0-9]+/)
  )

  const fromText = _.compose(
    _.match(/[0-9]+/)
  )

  return jq.children('.ranknnm').children().attr('alt')
   ? fromAlt(jq.children('.ranknnm').children().attr('alt'))
   : fromText(jq.children('.ranknnm').text())
}
Peter Chapman
@peterchappy
Dec 09 2017 19:30

Hi guys :wave:
Someone mentioned I should post this question here. Why am I unable to pipe into a recursive function?

const result = R.ifElse(
  banks => R.uniq(banks).length !== banks.length,
  R.pipe(R.length, R.subtract(R.__, 1)),
  R.pipe(createNewState, result)
)

I get ReferenceError: result is not defined

Mike Lambert
@lax4mike
Dec 09 2017 19:32
do you need the pipe in the else branch?
or should the else branch simply be createNewState?
what does createNewState accept as an argument, a bank or a result?
Peter Chapman
@peterchappy
Dec 09 2017 19:33
As in have createNewState call result?
it takes banks
I have it working fine like
const result = R.ifElse(
  banks => R.uniq(banks).length !== banks.length,
  banks => banks.length - 1,
  banks => result(createNewState(banks))
)
I was more just curious why the first example doesn't work
Mike Lambert
@lax4mike
Dec 09 2017 19:34
and you initially call it by result(createNewState(banks))?
Peter Chapman
@peterchappy
Dec 09 2017 19:35
no, it's called initially like result(banks)
Mike Lambert
@lax4mike
Dec 09 2017 19:36
interesting
i'm not sure why the pipe version doesn't work if that 2nd version works
it's probably because the pipe is setup before the if/else is executed
and banks => result(createNewState(banks)) is lazy, ie, only invoked when it's needed
Kurt Milam
@kurtmilam
Dec 09 2017 20:40
@peterchappy banks => R.pipe(createNewState, result)(banks) will also work.
In your first example, you're calling result before it's been defined.
Kurt Milam
@kurtmilam
Dec 09 2017 20:45
const result = x => R.ifElse(
  banks => R.uniq(banks).length !== banks.length,
  banks => banks.length - 1,
  banks => result(createNewState(banks))
)(x)
That will also work.