These are chat archives for ramda/ramda

18th
Mar 2015
Eero Saynatkari
@rue
Mar 18 2015 00:00
Well, not exactly plain expressions
Scott Sauyet
@CrossEye
Mar 18 2015 00:00
:smiling_imp:
Danny Fritz
@dannyfritz
Mar 18 2015 00:00
cool @CrossEye i'll give this a keen eye
Scott Sauyet
@CrossEye
Mar 18 2015 00:01
It was an interesting problem that kept me thinking as I drove to my errands. Had to try it as soon as I was free.
Danny Fritz
@dannyfritz
Mar 18 2015 00:01
ohhhhh, i see how you did it
you kept the local vars in the accumulator. very cool
Scott Sauyet
@CrossEye
Mar 18 2015 00:02
It doesn't take on the issues of leading or trailing nulls, which really should be addressed. But how?
Danny Fritz
@dannyfritz
Mar 18 2015 00:03
in mine i just threw an error. haha http://jsbin.com/halalo/3/edit?js,console
  if (emptyCheck(_.head(arrWithEmpties))) {
    throw new Error('First value can\'t be empty.');
  }
  if (emptyCheck(_.last(arrWithEmpties))) {
    throw new Error('Last value can\'t be empty.');
  }
Scott Sauyet
@CrossEye
Mar 18 2015 00:04
Fair enough.
@lapanoid: It's supposed to be the same idea as the Haskell, wrapping up the ability to access and 'mutate' a (possibly deeply-nested) property of a data structure. Nothing prevents actual mutation, but presumably good style would dictate something like assoc.
Hardy Jones
@joneshf
Mar 18 2015 02:39
@dannyfritz that looks like a sliding window problem
which is comonadic in nature
Danny Fritz
@dannyfritz
Mar 18 2015 02:40
is it still sliding window if the window size is variable?
Hardy Jones
@joneshf
Mar 18 2015 02:40
variable in what regards?
the size of the window changes at each iteration?
Danny Fritz
@dannyfritz
Mar 18 2015 02:40
how many consecutive null entries in this case
Hardy Jones
@joneshf
Mar 18 2015 02:41
hmm, I dunno what the official description for sliding window is
So if you don't have to know up front, then sure :)
but in any case, it's comonadic
because the value you're computing at each element depends on the surrouding values
Danny Fritz
@dannyfritz
Mar 18 2015 02:42
does that just mean 2 monads? as in co-monadic?
Hardy Jones
@joneshf
Mar 18 2015 02:42
har har
oh, that was a typo, not a joke
sorry
Danny Fritz
@dannyfritz
Mar 18 2015 02:43
haah yeah
just saw that lol
Hardy Jones
@joneshf
Mar 18 2015 02:43
nah, it's a different thing
just a sec, I'm not sur eif ramda has things for working with comonad ideas
Hardy Jones
@joneshf
Mar 18 2015 03:00
yeah, I'm not seeing anything
well the idea is that, if you have the rest of the array at each iteration, you can interpolate right?
so if you array was like in your example: [1, null, null, 4]
then the first element you could be focused on 1 and have [null, null, 4] to work with
1 is a number, so just return that
oh, hmm
you need more than that
more like a zipper
still comonadic though
so for each element you focus on, you have everything before that element and everything after it
so for the first element, you focus on 1 and have [] before, and [null, null, 4] after
second element, you focus on null and have [1] before and [null, 4] after
thirdt element, you focus on null and have [1, null] before and [4] after
and final element, you focus on 4 and have [1, null, null] before and [] after
Hardy Jones
@joneshf
Mar 18 2015 03:05
so you can sort of see how you'd interpolate with those arguments
if it's a number, nothing is needed
if it's null then do some work
but the idea is like everything else in fp where you break it down to just a simple function that does the bits
and compose it with something that works on the whole thing
like how map does Functor stuff
and chain does Monad stuff
you need something similar to extend to do Comonad stuff
but in this case actually zipper stuff
I don't think it'd be easy in ramda to try and do it that way at the moment though
just something to keep in the back of your mind
Hardy Jones
@joneshf
Mar 18 2015 03:15
OH!
maybe you could
if you zip together inits and tails you get exactly that, thenjust map over it
but there's no inits and tails
hmm
Danny Fritz
@dannyfritz
Mar 18 2015 03:40
@joneshf like do a partition at each location?
[left] [current] [right]
Hardy Jones
@joneshf
Mar 18 2015 04:16
yeah
Asaf
@asaf-romano
Mar 18 2015 09:08
is there a function-version of defaultTo?
seems useful.
Raine Virta
@raine
Mar 18 2015 09:52
any idea why grunt jsdoc gives me this error? https://gist.github.com/raine/7325ab0c69d32250bed7
Scott Sauyet
@CrossEye
Mar 18 2015 11:38
@raine. Don't know. I will look at it when I get in front of a computer.
Raine Virta
@raine
Mar 18 2015 11:42
cheers
Scott Sauyet
@CrossEye
Mar 18 2015 11:47
@asaf-romano: are you suggesting a version where the second argument is a function or one where both arguments are?
I suppose the latter would be more flexible and could yields the behavior of the former when paired withalways. We don't have it, but it sounds like an interesting idea. Care to create a PR?
Scott Sauyet
@CrossEye
Mar 18 2015 12:13
I suppose the latter would be more flexible and could yields the behavior of the former when paired withalways. We don't have it, but it sounds like an interesting idea. Care to create a PR?
Scott Sauyet
@CrossEye
Mar 18 2015 14:09
@raine: I don't get that error, but I have other problems with the documentation tasks. I Can't build it either.... once again.
Walle Cyril
@GrosSacASac
Mar 18 2015 14:35
how can I remove all . and , in a string
with R.replace(/foo/g, 'bar', 'foo foo foo'); //=> 'bar bar bar'
Danny Fritz
@dannyfritz
Mar 18 2015 14:38
Raine Virta
@raine
Mar 18 2015 14:45
CrossEye: what about if you do fresh clone and try to run it
Asaf
@asaf-romano
Mar 18 2015 15:44
@CrossEye I needed the former, but both would work, as you say.
I'll try to find time and file it tomorrow.
Danny Arnold
@despairblue
Mar 18 2015 18:35
This message was deleted
Scott Sauyet
@CrossEye
Mar 18 2015 19:13
@raine I had other problems with a fresh clone. Those had to do with the environment I'm running in at work, and the bower stuff didn't work. Once I manually copied in the bower files it ran without error but didn't actually create the files. I will try to look at this soon although it might not be today.
Raine Virta
@raine
Mar 18 2015 19:14
CrossEye: thanks. i'll debug more also
got some ideas for the docs site and for that i have to get it run locally
Scott Sauyet
@CrossEye
Mar 18 2015 19:15
@asaf-romano: I look forward to seeing it. No guarantees it'll be accepted. The hardest thing may be finding a good name.
@raine: same with me. @buzzdecafe always seems to be able to get it to work.
Raine Virta
@raine
Mar 18 2015 19:19
speaking of names, what do you call it when you have data where you have data points for each minute and you reduce it into data points for each hour by summing the minutes?
lowering the resolution, so to speak
Walle Cyril
@GrosSacASac
Mar 18 2015 20:42
can someone give me a function which return true if a given string has half or more of its character identical
f("xxa") --> true
f("normal text") --> false
Raine Virta
@raine
Mar 18 2015 20:43
split by character, group by character, take the most frequent and compare the length of original string
Walle Cyril
@GrosSacASac
Mar 18 2015 20:43
how do you do that ?
Raine Virta
@raine
Mar 18 2015 20:46
well isn't that a great exercise
Walle Cyril
@GrosSacASac
Mar 18 2015 20:48
I confess I am a bit lost
Danny Fritz
@dannyfritz
Mar 18 2015 20:50
@GrosSacASac http://goo.gl/4O7TNY
Walle Cyril
@GrosSacASac
Mar 18 2015 20:52
you saved me
Danny Fritz
@dannyfritz
Mar 18 2015 20:52
saved you from what?
Walle Cyril
@GrosSacASac
Mar 18 2015 20:54
I do not know
Walle Cyril
@GrosSacASac
Mar 18 2015 21:11
Why is there no random function ?
How can I have a random number between 0 and x ?
Scott Sauyet
@CrossEye
Mar 18 2015 21:17
We try to stress referential integrity, meaning that an expression can always be replaced with its value, without changing behavior. By definition, that's not going to happen with a random function.
An experimental pseudo-random number generator based on FP principles used to be included as an optional extension. But it never was a good fit.
Walle Cyril
@GrosSacASac
Mar 18 2015 21:21
I know that a random function is never a pure function, but please put a random function in Ramda, it is so usefull
Just write warning in the doc
Hardy Jones
@joneshf
Mar 18 2015 21:22
@GrosSacASac you don't have to use ramda exclusively
you can use some other random thing from somewhere
Math.random for instance
Walle Cyril
@GrosSacASac
Mar 18 2015 21:23
thanks I will try it
Hardy Jones
@joneshf
Mar 18 2015 21:23
or any number of libraries on npm
Walle Cyril
@GrosSacASac
Mar 18 2015 21:36
where do I find the Math library ?
John-David Dalton
@jdalton
Mar 18 2015 21:38
Math is built-in to the lang. See http://es5.github.io/#x15.8
Walle Cyril
@GrosSacASac
Mar 18 2015 21:38
awesome
Raine Virta
@raine
Mar 18 2015 21:53
CrossEye: figured out at least the undefined is not a function error
it's because R.not was renamed to R.nix, and 0.11.0, the version of ramda in dev deps naturally doesn't have that
Scott Sauyet
@CrossEye
Mar 18 2015 21:56
Ah, makes sense. But what code is calling Ramda inside grunt jsdoc?
Raine Virta
@raine
Mar 18 2015 21:56
jsdoc-template/publish.js
it should either use stable ramda API or require ramda from the repo itself
Scott Sauyet
@CrossEye
Mar 18 2015 21:57
@GrosSacASac: https://github.com/ramda/ramda/pull/590/files shows the Random extension in its final state as it was being pulled out.
@raine: yup.
Raine Virta
@raine
Mar 18 2015 21:58
"stable" as in latest from npm
Scott Sauyet
@CrossEye
Mar 18 2015 21:59
Yes, and we include that for our build, so it's already available.
Raine Virta
@raine
Mar 18 2015 21:59
from dist?
Scott Sauyet
@CrossEye
Mar 18 2015 22:02
it's in root/node_modules, as we need it for the script that builds the dist.
Raine Virta
@raine
Mar 18 2015 22:03
you mean ramda?
Scott Sauyet
@CrossEye
Mar 18 2015 22:03
yes
Raine Virta
@raine
Mar 18 2015 22:03
yeah, it's there, but it's 0.11.0
Scott Sauyet
@CrossEye
Mar 18 2015 22:04
so we should be able to use that rather than the one out of dist
Raine Virta
@raine
Mar 18 2015 22:04
it's using the one from node_modules currently
that's why it's not working
Scott Sauyet
@CrossEye
Mar 18 2015 22:04
oh, I misunderstood what you were saying.
So we simply need to update the publish script to use nix?
Raine Virta
@raine
Mar 18 2015 22:06
publish script uses the ramda from package.json devDeps: https://github.com/ramda/ramda/blob/master/package.json#L74
you have to either use ramda API that latest from npm has, or require built ramda from dist
a) means -nix +not b) require(__dirname + '/../../../dist/ramda')
Raine Virta
@raine
Mar 18 2015 22:15
to me the second option seems more maintainable
Scott Sauyet
@CrossEye
Mar 18 2015 22:19
agreed. Wonder how it got to nix anyway. Probably overzealous in the changeover.
Raine Virta
@raine
Mar 18 2015 22:50
is there a specific reason why ramda is not used in the docs' javascript?
Raine Virta
@raine
Mar 18 2015 23:26
alright, made a pr