-
-
Notifications
You must be signed in to change notification settings - Fork 95
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
Add S.reverse #220
Conversation
//# reverse :: [a] -> [a] | ||
//. | ||
//. Takes an array and returns an array of the its elements in | ||
//. reversed order. |
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.
Let's make it clear that this function is not Array-specific. I suggest:
Returns the elements of the given list in reverse order.
@davidchambers sorry it took me so long. As for the implementation: I also added a check for |
{}, | ||
[List(a), List(a)], | ||
function reverse(xs) { | ||
var result = []; |
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.
⬅️ ⬅️ Two spaces for indentation, please. :)
9e6a539
to
07e1ca6
Compare
[List(a), List(a)], | ||
function reverse(xs) { | ||
var result = []; | ||
if (_type(xs) === 'String') return reverse(xs.split('')).join(''); |
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.
Let's switch the two lines above. result
is unused in the String case.
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.
No problem - I just usually put it on top since it does not matter anyhow because of variable hoisting. I'll move it.
Thanks for the updates, Tobi. LGTM aside from the two minor stylistic issues I mentioned above. :) |
🌳 |
Fixes #196