-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
tweak some error messages to be more like WMA... #1094
Conversation
in particular Get::noopen, {First,Last,Most}::normal
@@ -589,24 +590,24 @@ class First(Builtin): | |||
>> First[a + b + c] | |||
= a | |||
>> First[x] | |||
: Nonatomic expression expected. | |||
: Nonatomic expression expected at position 1 in First[x]. | |||
= First[x] | |||
>> First[{}] | |||
: {} has zero length and no first element. | |||
= First[{}] | |||
""" | |||
|
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.
First
and Last
should have a default value as second arg and attribute A_HOLD_REST
.
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.
@axkr, you are right:
In[1]:= First[a]
First::normal: Nonatomic expression expected at position 1 in First[a].
Out[1]= First[a]
In[2]:= First[a, b]
Out[2]= b
In[3]:= First[a, b, c]
First::argt: First called with 3 arguments; 1 or 2 arguments are expected.
Out[3]= First[a, b, c]
In[4]:= ?? First
Out[4]= First[expr] gives the first element in expr
> . First[expr, def] gives the first element if it exists, or def
> otherwise.
Attributes[First]={HoldRest, Protected}
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.
Thanks - this should be handled now.
Properties on First and Last should be A_HOLD_REST (axel) Check that arguments are 1 or 2 (mmatera)
3f264ed
to
a7bf87b
Compare
a7bf87b
to
73b99f0
Compare
-- this time, for sure https://www.youtube.com/watch?v=pc4IFIXcDcs
f7828bb
to
d8f3987
Compare
mathics/builtin/list/eol.py
Outdated
and len == 2 | ||
and isinstance(first_elem, Atom) | ||
): | ||
return expr.elements[1].evaluate(evaluation) |
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.
Just a comment: to call the evaluate(evaluation)
method at the end is not needed: it is going to be called in the next rewrite_apply_eval
iteration
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.
Ok - thanks. Will remove the explicit call.
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.
LGTM. Merge when you feel it is ready.
in particular Get::noopen, {First,Last,Most}::normal