These are chat archives for ramda/ramda

3rd
Jul 2017
Jonah
@jonahx
Jul 03 2017 02:39
Given a list of functions of one argument fs and list of values xs, what is the best way in ramda to produce the list of those functions applied pairwise to the correspoending values (the lists are guaranteed to be of equal size) — ie, [f0(x0), f1(x1), …]?
Lucas Schejtman
@lucasschejtman
Jul 03 2017 03:19
R.zipWith(R.call, fs, xs)
Jonah
@jonahx
Jul 03 2017 03:34
@lucasschejtman ty
Johnny Hauser
@m59peacemaker
Jul 03 2017 04:22
Can this be fp golfed into between(0, 10, 4) ?
const isLt = flip(lt)
const isGt = flip(gt)
const between = useWith(both, [ isGt, isLt ])
between(0, 10)(4)
Lucas Schejtman
@lucasschejtman
Jul 03 2017 04:27
const between = uncurryN(3, useWith(both, [ isGt, isLt ]))
Jonah
@jonahx
Jul 03 2017 04:51
Working on a ramda function to generate this variation on pascal's triangle in which each number is the sum not only of the left and right numbers above it, but of the complete left and right diagonals above it. The commented example should clarify. Looking for the conceptually simplest solution, and one that doesn't use indexes. My solution sums the column above, then uses rotations to align the diagnols, turning that into a column sum problem as well. Can you improve it?
/*

                  1                               1
                1   1                             1   1
              2   2   2                           2   2   2
            4   5   5   4                ===      4   5   5   4
          8  12  14  12   8                       8   12  14  12   8
       16  28  37  37  28  16                     16  28  37  37  28  16
     32  64  94  106 94  64  32                   32  64  94  106 94  64  32
   64  144 232 289 289 232 144 64                 64  144 232 289 289 232 144 64
 128 320 560 760 838 760 560 320 128              128 320 560 760 838 760 560 320 128
*/

const rotateR = R.curry((n, arr) => R.pipe(R.splitAt(arr.length - n), R.reverse, R.flatten)(arr));

function tri(n, ret=null) {
  if (!ret) return tri(n-1, [[1]])
  if (!n) return ret
  ret = R.map(R.concat(R.__, [0]), ret)

  const rotFns = R.map(rotateR, R.reverse(R.range(1, ret.length+1)))
  const rotated = R.zipWith(R.call, rotFns, ret)
  const nextRight = R.transpose(rotated).map(R.sum)

  const nextLeft = R.transpose(ret).map(R.sum)
  const next = R.zipWith(R.add, nextLeft, nextRight)
  return tri(n-1, R.concat(ret, [next]))
}
Jonah
@jonahx
Jul 03 2017 04:57
on reflection, the whole business with the rotations isn’t even needed, because of symmetry. still curious if that part could be improved, assuming it was needed
PvdH
@MidnightP
Jul 03 2017 07:38

I receive an annoying error when trying to use mergeDeepLeft. R.mergeDeepLeft is not a function...

R = require('ramda')
R.mergeDeepLeft(a, b)

a and b are objects. I checked the R object and indeed, mergeDeepLeft is not there. I am using the latest version. Any help?

Denis Stoyanov
@xgrommx
Jul 03 2017 10:35
@jonahx pascal triangle are binominal coefficients
Jonah
@jonahx
Jul 03 2017 13:54
@xgrommx it’s not a normal pascal. check out the example in the code
Denis Stoyanov
@xgrommx
Jul 03 2017 14:30
@jonahx I think for your problem need smth like iterate but ramda doesn't work with infinity streams and this small example with iterators and ramda together (normal pascal) https://jsbin.com/lumezav/2/edit?html,js,console
Denis Stoyanov
@xgrommx
Jul 03 2017 15:01
or with mostjs iterate (also u can do it with rx (maybe) using expand operator) https://jsbin.com/lumezav/6/edit?html,js,console
Michael Rosata
@mrosata
Jul 03 2017 15:23
@MidnightP what do you get if you do R.type(R.mergeDeepLeft)?
Galileo Sanchez
@galileopy
Jul 03 2017 17:03
where can I learn about bundled projects that have gitignored dist but have only the dist folder published on npm?
Michael Rosata
@mrosata
Jul 03 2017 17:05
@galileopy If there is no .npmignore file, then the .gitignore is used. So if you don't ignore dist in the .npmignore file then it will publish to npm. Not sure if that's what your asking
Francisco Ryan Tolmasky I
@tolmasky
Jul 03 2017 17:09
what command do I use to build the docs?
Rick Medina
@rickmed
Jul 03 2017 17:20
Function.prototype.ᐅ = function(f) {
  const self = this
  return function(...args) {
    return f(self(...args))
  }
}

const doubleSay = str => str + ", " + str
const capitalize = str => str[0].toUpperCase() + str.substring(1)
const exclaim = str => str + '!'

const program =
  doubleSay
  .ᐅ(capitalize)
  .ᐅ(exclaim)

program('hello')  //=> "Hello, hello!"
@rickmed ah! u was first
Rick Medina
@rickmed
Jul 03 2017 17:39
:muscle: :)
Denis Stoyanov
@xgrommx
Jul 03 2017 17:40
@rickmed but my version almost like in Elm :smile:
Bijoy Thomas
@bijoythomas
Jul 03 2017 17:44
:open_mouth:
Rick Medina
@rickmed
Jul 03 2017 17:45
@xgrommx I wonder where to find those interesting sigils, I wanted something like ">>"
Kurt Milam
@kurtmilam
Jul 03 2017 17:46
@rickmed These should all be valid as of ES6 and Unicode 8: https://codepoints.net/search?IDS=1
Read more about it here.
Johnny Hauser
@m59peacemaker
Jul 03 2017 17:47
@lucasschejtman ah, so that's what uncurry is about. Neat :)
Thanks!
Galileo Sanchez
@galileopy
Jul 03 2017 17:47
@mrosata I was looking for the prepublish script, and files entries in package.json, it allows you to build your files and publish only the built version while keeping your source code out of the npm registry
Rick Medina
@rickmed
Jul 03 2017 17:52
@kurtmilam tried a couple but didn't work :(
Kurt Milam
@kurtmilam
Jul 03 2017 17:52
tried where?
Rick Medina
@rickmed
Jul 03 2017 17:52
if they were valid
Kurt Milam
@kurtmilam
Jul 03 2017 17:53
Interesting. I have tried several and haven't come across one yet that the checker reports as being invalid.
Rick Medina
@rickmed
Jul 03 2017 17:56
@kurtmilam » (00BB)
Kurt Milam
@kurtmilam
Jul 03 2017 17:59
That doesn't seem to be in the category to which I linked.
I linked to the category including characters with the trait ID Start=true. 00BB has ID Start=false. (scroll down)
Kurt Milam
@kurtmilam
Jul 03 2017 18:07
REPL
const ᐤ = 
  f => g => h =>
  f( g ( h ) )
ᐤ( toUpper )( reverse )( 'a man, a plan, a canal, panama' )
//-> "AMANAP ,LANAC A ,NALP A ,NAM A"
Denis Stoyanov
@xgrommx
Jul 03 2017 18:08
ugly...
sorry =)
Kurt Milam
@kurtmilam
Jul 03 2017 18:08
:D
Denis Stoyanov
@xgrommx
Jul 03 2017 18:08
toUpper.ᐤ ( reverse )
Kurt Milam
@kurtmilam
Jul 03 2017 18:09
no need to apologize. de gustibus non est disputandum.
Rick Medina
@rickmed
Jul 03 2017 18:27
@kurtmilam mm, I think when I searched it does it globally
Kurt Milam
@kurtmilam
Jul 03 2017 18:28
Interesting. My link ends in ?IDS=1, which should only return characters with ID Start=true
Rick Medina
@rickmed
Jul 03 2017 18:34
@kurtmilam :thumbsup:
PvdH
@MidnightP
Jul 03 2017 20:38
@mrosata I get "Undefined"...
Francisco Ryan Tolmasky I
@tolmasky
Jul 03 2017 20:51
I get "make: * No rule to make target 0.24.0/fonts/glyphicons-halflings-regular.eot', needed byall'. Stop." when doing VERSION=0.24.0 make in ramada.github.io
Francisco Ryan Tolmasky I
@tolmasky
Jul 03 2017 21:04
is docs/index.html.handlebars the file to edit for making changes to documentation, it seems to be ignored...
Kevin Wallace
@kedashoe
Jul 03 2017 21:35
@tolmasky you are talking about ramda.github.io? it is npm run jsdoc
Bijoy Thomas
@bijoythomas
Jul 03 2017 21:52
@lucasschejtman
between = uncurryN(3, useWith(both, [isGt, isLt])) applied to between(5, 100, 4) returns true
Lucas Schejtman
@lucasschejtman
Jul 03 2017 23:05
yep, was highlighting uncurry more than providing a solution. Wrapping (uncurrying) both should fix it?
Bijoy Thomas
@bijoythomas
Jul 03 2017 23:08
you mean like useWith(uncurryN(3, both), [isGt, isLt])? No .. still the same .. both is sort of weird in that you can't all it with all 3 args .. prob because it support variadic args to the predicates
Lucas Schejtman
@lucasschejtman
Jul 03 2017 23:10
you should uncurry with 2 not 3
let me jump into the repl
Bijoy Thomas
@bijoythomas
Jul 03 2017 23:11
sorry .. yeah .. useWith(uncurryN(2, both), [isGt, isLt]) works
Lucas Schejtman
@lucasschejtman
Jul 03 2017 23:14
:+1:
Bijoy Thomas
@bijoythomas
Jul 03 2017 23:23
is there a way to make between curried .. so that it can take the three args all or one at a time?
ah .. nm .. just wrapping it with curryN works
never had to use uncurryN and curryN together .. @lucasschejtman .. thanks for highlighting uncurryN