Closed ali-p-q closed 2 years ago
Section 3.8.1 of the book, titled Closures, has this code snippet:
fun addPair(a, b) { return a + b; } fun identity(a) { return a; } print identity(addPair)(1, 2); // Prints "3".
I believe the last line should have been typed:
print identity(addPair(1, 2)); // Prints "3".
Source code file/line: https://github.com/munificent/craftinginterpreters/blame/master/book/the-lox-language.md#L631
addPair is a first-class function.
addPair
Duplicate of #852 . Thought I had explained this once already :)
Yes, as #852 states, this code is correct (though a little unusual).
Section 3.8.1 of the book, titled Closures, has this code snippet:
I believe the last line should have been typed:
print identity(addPair(1, 2)); // Prints "3".
Source code file/line: https://github.com/munificent/craftinginterpreters/blame/master/book/the-lox-language.md#L631