Cale Gibbard wrote:
On 17/08/06, Brian Hulley [EMAIL PROTECTED] wrote:
In contrast, a programming language should be based on general
concepts uniformly applied. In Haskell we have operators,
identifiers, prefix application using an identifier and infix
application using a symbol, and a uniform
Hi Brian and others,
I posted the original question because I didn't know how to get map
(-2) working.
Since the original posting, many people have presented _a priori_
arguments about the merits of different approaches, most importantly
whether or not to abandon the unary - operator. As a
In C, it wouldn't be, since there, unary ops always bind tighter than infix
ops, and the precedences used in C are also used in C++, Java, C#,
Javascript etc, and even ISO Prolog obeys the rule that unary minus binds
tighter so making unary minus have the same precedence as infix minus just
makes
On 17/08/06, Brian Hulley [EMAIL PROTECTED] wrote:
Jared Updike wrote:
In other words, superscripts bind tighter than prefix ops but prefix
ops bind tighter than infix.
I see. My point is that there already exists a convention[1] that the
way to type in
2
-4
is -4^2 which means
The code in the subject generates an error. I understand why this is
(- is treated as part of the number), but I don't know how to solve
it, ie how to tell Haskell that - is a function/binary operator?
Thanks,
Tamas
___
Haskell-Cafe mailing list
Tamas,
The code in the subject generates an error. I understand why this is
(- is treated as part of the number), but I don't know how to solve
it, ie how to tell Haskell that - is a function/binary operator?
What about
map (flip (-) 2) [1 .. 5]
or
map (+ (- 2)) [1 .. 5]
?
HTH,
On 17/08/06, Tamas K Papp [EMAIL PROTECTED] wrote:
The code in the subject generates an error. I understand why this is
(- is treated as part of the number), but I don't know how to solve
it, ie how to tell Haskell that - is a function/binary operator?
There's a Prelude function for exactly
Tamas K Papp wrote:
The code in the subject generates an error. I understand why this is
(- is treated as part of the number), but I don't know how to solve
it, ie how to tell Haskell that - is a function/binary operator?
Actually looking at the Haskell98 report, -2 seems to be treated as
I'd have thought it would have been simpler to just make the rule that -2
(no spaces between '-' and '2') would be a single lexeme
I'd have thought so too, until I implemented a parser with exponentiation.
It is easy to get confused and make a parser that is too eager to include
the minus sign
On Thu, Aug 17, 2006 at 11:14:32AM +0100, Brian Hulley wrote:
I'd have thought it would have been simpler to just make the rule that -2
(no spaces between '-' and '2') would be a single lexeme, and then people
could just use (negate x) or (0 - x) instead of having a special rule and a
whole
Jared Updike wrote:
-4^2is not the same whether parsed as
(-4)^2 or -(4^2) (the correct version)
Basically, before someone argues this with me,
-4^2 should parse the same as
- 4^2 which should be the same thing as
0 - 4^2
I'd argue that -4^2 should parse as (-4)^2 in the same way
On 17/08/06, Brian Hulley [EMAIL PROTECTED] wrote:
Literal highlighting in the editor would make it clear that x-2 === x (-2).
I think a basic issue is that at the moment it is strange that non-negative
numbers can be specified as literals but negative numbers can't - they can
only get in
I'd also argue that in maths the necessary brackets are implied by the
superscripting syntax
ASCII text parsing issues aside, in math,
2
-4 =?
(No you cannot ask if there is space between the 4 and the - symbol,
or if I meant (-4)^2 or -(4^2), or if I wrote a negative sign
Jared Updike wrote:
I'd also argue that in maths the necessary brackets are implied by
the superscripting syntax
ASCII text parsing issues aside, in math,
2
-4 =?
(No you cannot ask if there is space between the 4 and the - symbol,
or if I meant (-4)^2 or -(4^2), or if I
David House wrote:
On 17/08/06, Brian Hulley [EMAIL PROTECTED] wrote:
Literal highlighting in the editor would make it clear that x-2 ===
x (-2). I think a basic issue is that at the moment it is strange
that non-negative numbers can be specified as literals but negative
numbers can't - they
Yes but my point is that -4^2 is not the same as
2
-4
because the latter by convention means - (4^2).
In other words, superscripts bind tighter than prefix ops but prefix ops
bind tighter than infix.
I see. My point is that there already exists a convention[1]
On Fri, Aug 18, 2006 at 12:20:54AM +0100, Brian Hulley wrote:
data Integer = ... | -1 | 0 | 1 | ...
tells me that the negative and positive integers are on an equal footing.
Ie the language is sending out a mixed message about the integers, which
is confusing.
Not only that but there
Jared Updike wrote:
In other words, superscripts bind tighter than prefix ops but prefix
ops bind tighter than infix.
I see. My point is that there already exists a convention[1] that the
way to type in
2
-4
is -4^2 which means -(4^2) not (-4)^2 because - as a prefix op has the
same
18 matches
Mail list logo