Skip to content

Instantly share code, notes, and snippets.

@mjansen401
Created October 28, 2012 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjansen401/3968740 to your computer and use it in GitHub Desktop.
Save mjansen401/3968740 to your computer and use it in GitHub Desktop.
FP for OO typo
;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