Browse files

* src/main/clojure/alioth/nbody.clj: add += -= macros

  • Loading branch information...
1 parent 773fc4f commit e66a8e7ac530cf692fc3ad4023d54f6550c3c30f @swannodette swannodette committed Jan 21, 2012
Showing with 6 additions and 0 deletions.
  1. +6 −0 src/main/clojure/alioth/nbody.clj
View
6 src/main/clojure/alioth/nbody.clj
@@ -22,6 +22,12 @@
~@body
(recur ~adv))))
+(defmacro += [arr i expr]
+ `(aset ~arr ~i (+ (aget ~arr ~i) ~expr)))
+
+(defmacro -= [arr i expr]
+ `(aset ~arr ~i (- (aget ~arr ~i) ~expr)))
+
(def ^:const pi 3.141592653589793)
(def ^:const solar-mass (* 4 pi pi))
(def ^:const days-per-year 365.24)

0 comments on commit e66a8e7

Please sign in to comment.