【问题标题】:Passing vectors members individually单独传递向量成员
【发布时间】:2015-02-18 11:54:50
【问题描述】:

我正在尝试将参数列表传递给polygon 函数:

(polygon [1 2] [3 4] [5 6])

(polygon pairs) ;;Throws exception

其中对:

clojure.lang.LazySeq  ([2.2935636 48.8580886] [2.2933061 48.8582457] [2.2935366 48.8584053] [2.2935553 48.8583952] ...)

通过 LazySeq 得到clojure.lang.LazySeq cannot be cast to java.lang.Number

我正在使用此功能进行配对

(def pairs  (map vector  poly-x  poly-y))

如何解开这个向量,以便编译器单独处理传递的参数

多边形签名:

(defn polygon
  "Create a polygonal shape with the given set of vertices.
  points is a list of x/y pairs, e.g.:

    (polygon [1 2] [3 4] [5 6])
  "
  [& points])

【问题讨论】:

    标签: graphics clojure polygon seesaw


    【解决方案1】:

    当然 apply 是要走的路:

    (apply polygon pairs)
    

    【讨论】:

    • 接受这个告诉其他人这个问题已经得到了正确的回答。
    猜你喜欢
    • 1970-01-01
    • 2020-09-06
    • 2016-12-17
    • 1970-01-01
    • 2015-01-04
    • 2021-06-24
    • 2017-05-16
    • 1970-01-01
    • 2012-06-27
    相关资源
    最近更新 更多