我正在尝试在 Clojure 中填充 ArrayList,但收到以下错误消息
java.util.ArrayList 不能转换为 clojure.lang.IFn
这是我的代码:
(ns blackhole-v1.core
(:import [java.util ArrayList])
(:import [toxi.geom Vec2D])
(:use [quil.core]))
(def particles (new ArrayList))
(defn add-particle []
; (particles (.add (new Vec2D (random (width)) (random (height)))))
(doto (particles)
(.add (new Vec2D (random (width)) (random (height))))))
(defn setup []
(smooth)
(background 0)
(add-particle))
(defn draw []
(background 0)
(dotimes [i (.size particles)]
(ellipse (.x (.get particles i)) (.y (.get particles i)) 20 20)))
(defsketch blackhole-v1
:title "black hole v1"
:setup setup
:draw draw
:size [640 480])
任何想法我做错了什么?