Skip to content
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

[wip] add first function and tests to mirror last #87

Closed
wants to merge 1 commit into from

Conversation

stoeffel
Copy link
Contributor

No description provided.

@stoeffel stoeffel mentioned this pull request Apr 12, 2015
Closed
@tjmehta
Copy link
Owner

tjmehta commented Apr 12, 2015

last was created to avoid arr[arr.length-1], first doesn't seem as useful as it is always arr[0]

@stoeffel
Copy link
Contributor Author

Yes, but it's useful for composing new functions.

var capitalize = converge(
  function(head, tail) { return head + tail; },
  [compose(
    function(str) { return str.toUpperCase(); },
    first
  ),
  tail]
);

capitalize('hello'); // => 'Hello'

refs #88

@tjmehta
Copy link
Owner

tjmehta commented Apr 14, 2015

For compose, first is equivalent to pluck('[0]')

@stoeffel
Copy link
Contributor Author

For compose, first is equivalent to pluck('[0]')

Yes, you are right. I still think it's much more expressive and since it's really common in FP it deserves to be it's own function. But if you think it's overkill feel free to close this PR.

@podviaznikov
Copy link

I would add first for compose. Seems more intuitive then pluck('[0]').

@tjmehta
Copy link
Owner

tjmehta commented Apr 17, 2015

I do like 101 having mirrors to existing utils; however, maybe in this case it is just a lack of documentation? Do you all think that documentation would be sufficient here?

@tjmehta
Copy link
Owner

tjmehta commented Apr 17, 2015

On a similar note, 101/last toStrings its argument if it is not a "list". This behavior is probably not useful (do you all agree?). I wouldn't mind creating a first as a convenience util that is as simple as pluck('[0]') but maybe we should simplify last. Thoughts?

@stoeffel
Copy link
Contributor Author

👍 on simplifying last. And probably you are right first is out of scope for 101.

Do you all think that documentation would be sufficient here?

yop. I will make a pr as soon as I have time.

@tjmehta tjmehta changed the title add first function and tests to mirror last [wip] add first function and tests to mirror last May 25, 2015
@tjmehta
Copy link
Owner

tjmehta commented Jan 22, 2016

stale PR closing for now

@tjmehta tjmehta closed this Jan 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants