4 ms·
Yes, that line doesn't redefine the expression 2+2 as the author suggests; rather, it redefines the operator + as a function which only works on 2 and 2, and re
by samstokes 15y ago
Yes, that line doesn't redefine the expression 2+2 as the author suggests; rather, it redefines the operator + as a function which only works on 2 and 2, and returns 5 for those arguments. e.g.
Prelude> let 2+2=5 in 2+3
*** Exception: <interactive>:1:5-9: Non-exhaustive patterns in function +
- lelf 15y agoAnd, considering syntactic sugar for operators, fib and (+) examples are quite alike Prelude> let (+) 2 2 = 5; 4 + 2 = 42 in [2 + 2, (+) 4 2, 0 + 3] [5,42,*** Exception: <interactive>:1:5-29: Non-exhaustive patterns in function + Prelude> let fib 0 = 1 in fib 0 1