- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]

From: Wolfgang Lux <lux_at_helios.uni-muenster.de>

Date: Tue, 01 Dec 1998 14:51:34 +0000

So, here are my (I think correct) solutions:

1) 1 | 3 | 5

2) 1 | 3 | 5

3) 1 | 5

The reason why 3 is a possible solution in the first two cases is, that even though the local definition of g looks like a variable, it really is not. As the report says at the bottom of page 5 "a defining equation f = g between functions will be interpreted in Curry as syntactic sugar for the corresponding defining equation f x = g x on base types." Therefore the local definition of g inside of f1 really was

where g x = incr x

g x = decr x

The same will also hold in case 2) even though h1 and h2 are variables. However the type inference will tell you that g must have type a->a, so the definition of g inside f2 is also really

where g x = h1 x

g x = h2 x

In the third case, g now really is a variable and not a function (type inference will tell you, that h3 be of type a->a->b->c and that g, h1, and h2 are of type a. Thus g is evaluated only once.

My final question, now, is: Does this really make sense to you? I really had to look twice into the report to convince myself that the solutions of 1) weren't 1|5. The variations 2) and 3) then were attempts to achieve this result.

Regards

Wolfgang

Date: Tue, 01 Dec 1998 14:51:34 +0000

So, here are my (I think correct) solutions:

1) 1 | 3 | 5

2) 1 | 3 | 5

3) 1 | 5

The reason why 3 is a possible solution in the first two cases is, that even though the local definition of g looks like a variable, it really is not. As the report says at the bottom of page 5 "a defining equation f = g between functions will be interpreted in Curry as syntactic sugar for the corresponding defining equation f x = g x on base types." Therefore the local definition of g inside of f1 really was

where g x = incr x

g x = decr x

The same will also hold in case 2) even though h1 and h2 are variables. However the type inference will tell you that g must have type a->a, so the definition of g inside f2 is also really

where g x = h1 x

g x = h2 x

In the third case, g now really is a variable and not a function (type inference will tell you, that h3 be of type a->a->b->c and that g, h1, and h2 are of type a. Thus g is evaluated only once.

My final question, now, is: Does this really make sense to you? I really had to look twice into the report to convince myself that the solutions of 1) weren't 1|5. The variations 2) and 3) then were attempts to achieve this result.

Regards

Wolfgang

-- Wolfgang Lux Phone: +49-251-83-38263 Institut fuer Wirtschaftinformatik FAX: +49-251-83-38259 Universitaet Muenster Email: lux_at_helios.uni-muenster.deReceived on Di Dez 01 1998 - 15:14:00 CET

*
This archive was generated by hypermail 2.3.0
: So Dez 03 2023 - 07:15:07 CET
*