-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
Adds List.last #816
Adds List.last #816
Conversation
(list_var, Var(Symbol::ARG_1)), | ||
( | ||
len_var, | ||
// Num.sub (List.len list) 1 |
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.
that's cool
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.
This is the right approach for now, but actually we should use subWrap
from #664 (once that's been implemented), because Num.sub
should do overflow checking, and there's no chance of overflow yet.
(I say "should do" because currently only Num.add
actually does it...maybe that's a good next project, actually!)
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.
Looks great! 🎉
Thanks @celsobonutti!
@@ -282,6 +282,23 @@ mod repl_eval { | |||
expect_success("List.sum [ 1.1, 2.2, 3.3 ]", "6.6 : F64"); | |||
} | |||
|
|||
// TODO add test cases for empty lists once error messages in the repl are correct |
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.
Sure enough! I've filed a bug for this: #818
(list_var, Var(Symbol::ARG_1)), | ||
( | ||
len_var, | ||
// Num.sub (List.len list) 1 |
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.
This is the right approach for now, but actually we should use subWrap
from #664 (once that's been implemented), because Num.sub
should do overflow checking, and there's no chance of overflow yet.
(I say "should do" because currently only Num.add
actually does it...maybe that's a good next project, actually!)
Adds List.last operation (see #664):
List.last : List elem -> Result elem [ ListWasEmpty ]*