🐛 Fix gpt/multiply docstring and gpt/abs Point record downcast

gpt/multiply had a copy-paste docstring from gpt/subtract claiming it
performs subtraction; corrected to accurately describe multiplication.

gpt/abs was using clojure.core/update on a Point record, which returns
a plain IPersistentMap instead of a Point instance, causing point?
checks on the result to return false. Replaced with a direct pos->Point
constructor call using mth/abs on each coordinate.

Signed-off-by: Andrey Antukh <niwi@niwi.nz>
This commit is contained in:
Andrey Antukh 2026-04-14 19:37:02 +00:00
parent 3d4c914daa
commit 179bb51c76

View File

@ -151,7 +151,7 @@
(dm/get-prop p2 :y))))
(defn multiply
"Returns the subtraction of the supplied value to both
"Returns the multiplication of the supplied value to both
coordinates of the point as a new point."
[p1 p2]
(assert (and (point? p1)
@ -509,12 +509,10 @@
(let [old-length (length vector)]
(scale vector (/ new-length old-length))))
;; FIXME: perfromance
(defn abs
[point]
(-> point
(update :x mth/abs)
(update :y mth/abs)))
(pos->Point (mth/abs (dm/get-prop point :x))
(mth/abs (dm/get-prop point :y))))
;; --- Debug