-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
intersperse for highland integration #1043
Conversation
if (idx === length - 1) { | ||
out = out.concat(list[idx]); | ||
} else { | ||
out = out.concat(list[idx], separator); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use push instead of concat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't we decide to use xs[xs.length] = x
? See #891.
I'd be happy for us to reverse that decision, but were we to do so it would be orthogonal to this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Push is just better in this case David
On Apr 21, 2015 9:51 PM, "David Chambers" notifications@github.com wrote:
In src/intersperse.js
#1043 (comment):
- * @param {*} separator The element to add to the list.
- * @param {Array} list The list to be interposed.
- * @return {Array} The new list.
- * @example
- * R.interpserse('n', ['ba', 'a', 'a']); //=> ['ba', 'n', 'a', 'n', 'a']
- */
+module.exports = _curry2(_checkForMethod('intersperse', function intersperse(separator, list) {- var out = [];
- var idx = -1;
- var length = list.length;
- while (++idx < length) {
- if (idx === length - 1) {
out = out.concat(list[idx]);
- } else {
out = out.concat(list[idx], separator);
Didn't we decide to use xs[xs.length] = x? See #891
#891.I'd be happy for us to reverse that decision, but were we to do so it
would be orthogonal to this change.—
Reply to this email directly or view it on GitHub
https://github.com/ramda/ramda/pull/1043/files#r28838931.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Push is just better in this case
Because we're pushing two values? Fair enough.
I'd like to use push
in all cases, for the record. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So would I. I'm really not sure how we ended up in our current state.
Agree with @megawac on |
* @func | ||
* @memberOf R | ||
* @category List | ||
* @sig * -> [a] -> [a] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that the return value has type [a]
the separator must have type a
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm. really, the input array could be [*]
and the return could be [*]
, so the whole sig probably should be * -> [*] -> [*]
.
Do we describe these with the most generic signature that fits or the expected one? Clearly
I don't know that we have any choice but to document the most generic version, but it certainly doesn't make me happy. |
I prefer |
i'm fine with that too. will revise when able |
Go ahead, twist my arm. Ok, ok, I'm convinced! |
044336e
to
c9db9d3
Compare
* @return {Array} The new list. | ||
* @example | ||
* | ||
* R.interpserse('n', ['ba', 'a', 'a']); //=> ['ba', 'n', 'a', 'n', 'a'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo, intersperse
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch, thanks
ping 👶 ➡️ 👴 |
🌳 |
intersperse for highland integration
Great and long awaited addition, thanks! I implemented same extension in lodash, but it wasn't accepted. |
No description provided.