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

Add S.reverse #220

Merged
merged 1 commit into from
May 27, 2016
Merged

Add S.reverse #220

merged 1 commit into from
May 27, 2016

Conversation

gilligan
Copy link
Contributor

Fixes #196

//# reverse :: [a] -> [a]
//.
//. Takes an array and returns an array of the its elements in
//. reversed order.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make it clear that this function is not Array-specific. I suggest:

Returns the elements of the given list in reverse order.

@gilligan
Copy link
Contributor Author

@davidchambers sorry it took me so long. As for the implementation: I also added a check for xs.length == 0 which returns xs right away. Does that look OK to you?

{},
[List(a), List(a)],
function reverse(xs) {
var result = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⬅️ ⬅️ Two spaces for indentation, please. :)

@gilligan gilligan force-pushed the add-reverse branch 5 times, most recently from 9e6a539 to 07e1ca6 Compare May 26, 2016 20:01
[List(a), List(a)],
function reverse(xs) {
var result = [];
if (_type(xs) === 'String') return reverse(xs.split('')).join('');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's switch the two lines above. result is unused in the String case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem - I just usually put it on top since it does not matter anyhow because of variable hoisting. I'll move it.

@davidchambers
Copy link
Member

Thanks for the updates, Tobi. LGTM aside from the two minor stylistic issues I mentioned above. :)

@davidchambers
Copy link
Member

🌳

@davidchambers davidchambers merged commit 8ef03e0 into sanctuary-js:master May 27, 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.

2 participants