
hello could someone explain the following differing results const id 0 5 -> 5 -- ie. 'takes' the 'last' one const (id 0) 5 -> 0 -- ie. 'takes' the 'first' one Thanks

On Jun 14, 2008, at 11:14 AM, odtaa48 wrote:
const id 0 5 -> 5 -- ie. 'takes' the 'last' one
The type of const is a -> b -> a. The first argument to const here is id and the second is 0, so the evaluation of const id 0 is going to result in id. Then we apply id to 5, yielding 5. Perhaps it would be more clear to write the expression is (const id 0) 5.
const (id 0) 5 -> 0 -- ie. 'takes' the 'first' one
Here the two arguments to const are (id 0) and 5. Since the effect of const is to toss out the second argument, this evaluates to id 0, which evaluates to simply 0. Does that help? - Jake McArthur

On Jun 14, 2008, at 6:14 PM, odtaa48 wrote:
hello could someone explain the following differing results const id 0 5 -> 5 -- ie. 'takes' the 'last' one const (id 0) 5 -> 0 -- ie. 'takes' the 'first' one
Thanks
You can easily see what is happening by rewriting the equations step by step. Remember that the const function is (\x y -> x) and the id function is (\x -> x). Example 1: const id 0 5 == (const id 0) 5 == id 5 == 5 Example 2: const (id 0) 5 == const 0 5 == 0 So, in both cases const takes the first. -- Sebastiaan.
participants (3)
-
Jake Mcarthur
-
odtaa48
-
Sebastiaan Visser