FP for OO typo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;Original function, p. 41 of FP for OO | |
user=> (def shift | |
(fn [this xinc yinc] | |
(Point (+ (x this) xinc) | |
(+ (y this) yinc)))) | |
CompilerException java.lang.RuntimeException: Unable to resolve symbol: y in this context, compiling:(NO_SOURCE_PATH:1) | |
;Updated function with correct :x :y key use | |
user=> (def shift | |
(fn [this xinc yinc] | |
(Point (+ (:x this) xinc) | |
(+ (:y this) yinc)))) | |
#'user/shift | |
user=> (shift (Point 1 200) -1 -200) | |
{:x 0, :y 0, :__class_symbol__ Point} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment