要做到这一点,最好的方法是什么?这里就是我有这么远从Clojure的两个点创建线段
(defn line-segment [start end]
(let [x-direction (abs (- (first end) (first start)))
y-direction (abs (- (last end) (last start)))]
(cond
(= 0 x-direction) (something ...)
(= 0 y-direction) (something ...))))
这是我的最终目标
user=> (line-segment [5 6] [5 8])
([5 6] [5 7] [5 8])
是的,没有对角线,仅x或y运动。
谢谢。
就像一副手套。谢谢! – 2011-03-28 20:29:06