clojure 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (1378) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -0
  3. data/LICENSE +23 -0
  4. data/README.rdoc +18 -0
  5. data/Rakefile +18 -0
  6. data/VERSION +1 -0
  7. data/bin/clj +13 -0
  8. data/epl-v10.html +261 -0
  9. data/lib/clojure/asm/AnnotationVisitor.class +0 -0
  10. data/lib/clojure/asm/AnnotationWriter.class +0 -0
  11. data/lib/clojure/asm/Attribute.class +0 -0
  12. data/lib/clojure/asm/ByteVector.class +0 -0
  13. data/lib/clojure/asm/ClassAdapter.class +0 -0
  14. data/lib/clojure/asm/ClassReader.class +0 -0
  15. data/lib/clojure/asm/ClassVisitor.class +0 -0
  16. data/lib/clojure/asm/ClassWriter.class +0 -0
  17. data/lib/clojure/asm/Edge.class +0 -0
  18. data/lib/clojure/asm/FieldVisitor.class +0 -0
  19. data/lib/clojure/asm/FieldWriter.class +0 -0
  20. data/lib/clojure/asm/Frame.class +0 -0
  21. data/lib/clojure/asm/Handler.class +0 -0
  22. data/lib/clojure/asm/Item.class +0 -0
  23. data/lib/clojure/asm/Label.class +0 -0
  24. data/lib/clojure/asm/MethodAdapter.class +0 -0
  25. data/lib/clojure/asm/MethodVisitor.class +0 -0
  26. data/lib/clojure/asm/MethodWriter.class +0 -0
  27. data/lib/clojure/asm/Opcodes.class +0 -0
  28. data/lib/clojure/asm/Type.class +0 -0
  29. data/lib/clojure/asm/commons/AdviceAdapter.class +0 -0
  30. data/lib/clojure/asm/commons/AnalyzerAdapter.class +0 -0
  31. data/lib/clojure/asm/commons/CodeSizeEvaluator.class +0 -0
  32. data/lib/clojure/asm/commons/EmptyVisitor.class +0 -0
  33. data/lib/clojure/asm/commons/GeneratorAdapter.class +0 -0
  34. data/lib/clojure/asm/commons/LocalVariablesSorter.class +0 -0
  35. data/lib/clojure/asm/commons/Method.class +0 -0
  36. data/lib/clojure/asm/commons/SerialVersionUIDAdder$Item.class +0 -0
  37. data/lib/clojure/asm/commons/SerialVersionUIDAdder.class +0 -0
  38. data/lib/clojure/asm/commons/StaticInitMerger.class +0 -0
  39. data/lib/clojure/asm/commons/TableSwitchGenerator.class +0 -0
  40. data/lib/clojure/core$_DOT__DOT___3630.class +0 -0
  41. data/lib/clojure/core$_EQ__EQ___3398.class +0 -0
  42. data/lib/clojure/core$_EQ___3291.class +0 -0
  43. data/lib/clojure/core$_GT__EQ___3390.class +0 -0
  44. data/lib/clojure/core$_GT___3382.class +0 -0
  45. data/lib/clojure/core$_LT__EQ___3374.class +0 -0
  46. data/lib/clojure/core$_LT___3366.class +0 -0
  47. data/lib/clojure/core$_PLUS___3332.class +0 -0
  48. data/lib/clojure/core$_SLASH___3350.class +0 -0
  49. data/lib/clojure/core$_STAR___3341.class +0 -0
  50. data/lib/clojure/core$__GT___3634.class +0 -0
  51. data/lib/clojure/core$___3358.class +0 -0
  52. data/lib/clojure/core$accessor__4294.class +0 -0
  53. data/lib/clojure/core$aclone__4211.class +0 -0
  54. data/lib/clojure/core$add_classpath__4707.class +0 -0
  55. data/lib/clojure/core$add_doc__5153.class +0 -0
  56. data/lib/clojure/core$add_watch__3697.class +0 -0
  57. data/lib/clojure/core$add_watcher__3703$fn__3705.class +0 -0
  58. data/lib/clojure/core$add_watcher__3703.class +0 -0
  59. data/lib/clojure/core$agent__3684.class +0 -0
  60. data/lib/clojure/core$agent_errors__3712.class +0 -0
  61. data/lib/clojure/core$aget__4217.class +0 -0
  62. data/lib/clojure/core$alength__4205.class +0 -0
  63. data/lib/clojure/core$alias__4367.class +0 -0
  64. data/lib/clojure/core$all_ns__4318.class +0 -0
  65. data/lib/clojure/core$alter__3759.class +0 -0
  66. data/lib/clojure/core$alter_meta_BANG___3750.class +0 -0
  67. data/lib/clojure/core$alter_var_root__4827.class +0 -0
  68. data/lib/clojure/core$amap__4725.class +0 -0
  69. data/lib/clojure/core$ancestors__4866$fn__4869.class +0 -0
  70. data/lib/clojure/core$ancestors__4866.class +0 -0
  71. data/lib/clojure/core$and__3308.class +0 -0
  72. data/lib/clojure/core$apply__3243.class +0 -0
  73. data/lib/clojure/core$areduce__4729.class +0 -0
  74. data/lib/clojure/core$array__4040.class +0 -0
  75. data/lib/clojure/core$array_map__4401.class +0 -0
  76. data/lib/clojure/core$aset__4224.class +0 -0
  77. data/lib/clojure/core$aset_boolean__4244.class +0 -0
  78. data/lib/clojure/core$aset_byte__4260.class +0 -0
  79. data/lib/clojure/core$aset_char__4264.class +0 -0
  80. data/lib/clojure/core$aset_double__4252.class +0 -0
  81. data/lib/clojure/core$aset_float__4248.class +0 -0
  82. data/lib/clojure/core$aset_int__4236.class +0 -0
  83. data/lib/clojure/core$aset_long__4240.class +0 -0
  84. data/lib/clojure/core$aset_short__4256.class +0 -0
  85. data/lib/clojure/core$asm_type__5683.class +0 -0
  86. data/lib/clojure/core$assert__4528.class +0 -0
  87. data/lib/clojure/core$assert_args__3659.class +0 -0
  88. data/lib/clojure/core$assoc__3148.class +0 -0
  89. data/lib/clojure/core$assoc_in__5075.class +0 -0
  90. data/lib/clojure/core$associative_QMARK___5102.class +0 -0
  91. data/lib/clojure/core$atom__3728.class +0 -0
  92. data/lib/clojure/core$await1__4014.class +0 -0
  93. data/lib/clojure/core$await__4007$count_down__4009.class +0 -0
  94. data/lib/clojure/core$await__4007.class +0 -0
  95. data/lib/clojure/core$await_for__4017$count_down__4019.class +0 -0
  96. data/lib/clojure/core$await_for__4017.class +0 -0
  97. data/lib/clojure/core$bases__4836.class +0 -0
  98. data/lib/clojure/core$bean__5303$fn__5305$fn__5307.class +0 -0
  99. data/lib/clojure/core$bean__5303$fn__5305.class +0 -0
  100. data/lib/clojure/core$bean__5303$fn__5321$thisfn__5323$fn__5324.class +0 -0
  101. data/lib/clojure/core$bean__5303$fn__5321$thisfn__5323.class +0 -0
  102. data/lib/clojure/core$bean__5303$fn__5321.class +0 -0
  103. data/lib/clojure/core$bean__5303$fn__5330.class +0 -0
  104. data/lib/clojure/core$bean__5303$fn__5333.class +0 -0
  105. data/lib/clojure/core$bean__5303$fn__5336.class +0 -0
  106. data/lib/clojure/core$bean__5303$fn__5339.class +0 -0
  107. data/lib/clojure/core$bean__5303$fn__5342.class +0 -0
  108. data/lib/clojure/core$bean__5303$fn__5346.class +0 -0
  109. data/lib/clojure/core$bean__5303$fn__5349.class +0 -0
  110. data/lib/clojure/core$bean__5303$snapshot__5315$fn__5317.class +0 -0
  111. data/lib/clojure/core$bean__5303$snapshot__5315.class +0 -0
  112. data/lib/clojure/core$bean__5303$v__5312.class +0 -0
  113. data/lib/clojure/core$bean__5303.class +0 -0
  114. data/lib/clojure/core$bigdec__4136.class +0 -0
  115. data/lib/clojure/core$bigint__4133.class +0 -0
  116. data/lib/clojure/core$binding__3672$var_ize__3674.class +0 -0
  117. data/lib/clojure/core$binding__3672.class +0 -0
  118. data/lib/clojure/core$bit_and__3509.class +0 -0
  119. data/lib/clojure/core$bit_and_not__3524.class +0 -0
  120. data/lib/clojure/core$bit_clear__3527.class +0 -0
  121. data/lib/clojure/core$bit_flip__3533.class +0 -0
  122. data/lib/clojure/core$bit_not__3503.class +0 -0
  123. data/lib/clojure/core$bit_or__3515.class +0 -0
  124. data/lib/clojure/core$bit_set__3530.class +0 -0
  125. data/lib/clojure/core$bit_shift_left__3539.class +0 -0
  126. data/lib/clojure/core$bit_shift_right__3542.class +0 -0
  127. data/lib/clojure/core$bit_test__3536.class +0 -0
  128. data/lib/clojure/core$bit_xor__3521.class +0 -0
  129. data/lib/clojure/core$boolean__4101.class +0 -0
  130. data/lib/clojure/core$bound_fn__4679$fn__4681.class +0 -0
  131. data/lib/clojure/core$bound_fn__4679.class +0 -0
  132. data/lib/clojure/core$butlast__3156.class +0 -0
  133. data/lib/clojure/core$byte__4089.class +0 -0
  134. data/lib/clojure/core$cast__3160.class +0 -0
  135. data/lib/clojure/core$char__4095.class +0 -0
  136. data/lib/clojure/core$class_QMARK___4824.class +0 -0
  137. data/lib/clojure/core$class__4043.class +0 -0
  138. data/lib/clojure/core$clear_agent_errors__3715.class +0 -0
  139. data/lib/clojure/core$clojure_version__5781.class +0 -0
  140. data/lib/clojure/core$coll_QMARK___5087.class +0 -0
  141. data/lib/clojure/core$comment__4501.class +0 -0
  142. data/lib/clojure/core$commute__3756.class +0 -0
  143. data/lib/clojure/core$comp__3775$fn__3777.class +0 -0
  144. data/lib/clojure/core$comp__3775.class +0 -0
  145. data/lib/clojure/core$comparator__3965$fn__3967.class +0 -0
  146. data/lib/clojure/core$comparator__3965.class +0 -0
  147. data/lib/clojure/core$compare__3304.class +0 -0
  148. data/lib/clojure/core$compare_and_set_BANG___3738.class +0 -0
  149. data/lib/clojure/core$compile__5065$fn__5067.class +0 -0
  150. data/lib/clojure/core$compile__5065.class +0 -0
  151. data/lib/clojure/core$complement__3551$fn__3553.class +0 -0
  152. data/lib/clojure/core$complement__3551.class +0 -0
  153. data/lib/clojure/core$concat__3255$cat__3269$fn__3270.class +0 -0
  154. data/lib/clojure/core$concat__3255$cat__3269.class +0 -0
  155. data/lib/clojure/core$concat__3255$fn__3257.class +0 -0
  156. data/lib/clojure/core$concat__3255$fn__3261.class +0 -0
  157. data/lib/clojure/core$concat__3255$fn__3265.class +0 -0
  158. data/lib/clojure/core$concat__3255.class +0 -0
  159. data/lib/clojure/core$cond__3237.class +0 -0
  160. data/lib/clojure/core$condp__5146$emit__5148.class +0 -0
  161. data/lib/clojure/core$condp__5146.class +0 -0
  162. data/lib/clojure/core$conj__3121.class +0 -0
  163. data/lib/clojure/core$cons__3107.class +0 -0
  164. data/lib/clojure/core$constantly__3560$fn__3562.class +0 -0
  165. data/lib/clojure/core$constantly__3560.class +0 -0
  166. data/lib/clojure/core$construct_proxy__5265.class +0 -0
  167. data/lib/clojure/core$contains_QMARK___3582.class +0 -0
  168. data/lib/clojure/core$count__3569.class +0 -0
  169. data/lib/clojure/core$counted_QMARK___5111.class +0 -0
  170. data/lib/clojure/core$create_ns__4312.class +0 -0
  171. data/lib/clojure/core$create_struct__4282.class +0 -0
  172. data/lib/clojure/core$ctor_sigs__5565$iter__5567__5569$fn__5570.class +0 -0
  173. data/lib/clojure/core$ctor_sigs__5565$iter__5567__5569.class +0 -0
  174. data/lib/clojure/core$ctor_sigs__5565.class +0 -0
  175. data/lib/clojure/core$cycle__3899$fn__3901.class +0 -0
  176. data/lib/clojure/core$cycle__3899.class +0 -0
  177. data/lib/clojure/core$dec__3422.class +0 -0
  178. data/lib/clojure/core$decimal_QMARK___4121.class +0 -0
  179. data/lib/clojure/core$declare__5118$fn__5120.class +0 -0
  180. data/lib/clojure/core$declare__5118.class +0 -0
  181. data/lib/clojure/core$def_aset__4233.class +0 -0
  182. data/lib/clojure/core$definline__4716.class +0 -0
  183. data/lib/clojure/core$defmacro__3190.class +0 -0
  184. data/lib/clojure/core$defmethod__3641.class +0 -0
  185. data/lib/clojure/core$defmulti__3638.class +0 -0
  186. data/lib/clojure/core$defn__3158.class +0 -0
  187. data/lib/clojure/core$defn___4565.class +0 -0
  188. data/lib/clojure/core$defonce__4973.class +0 -0
  189. data/lib/clojure/core$defstruct__4285.class +0 -0
  190. data/lib/clojure/core$delay_QMARK___3278.class +0 -0
  191. data/lib/clojure/core$delay__3275.class +0 -0
  192. data/lib/clojure/core$deref__3725.class +0 -0
  193. data/lib/clojure/core$derive__4877$tf__4880$fn__4882.class +0 -0
  194. data/lib/clojure/core$derive__4877$tf__4880.class +0 -0
  195. data/lib/clojure/core$derive__4877.class +0 -0
  196. data/lib/clojure/core$descendants__4873.class +0 -0
  197. data/lib/clojure/core$destructure__4413$pb__4415$pmap__4419$fn__4421$fn__4423.class +0 -0
  198. data/lib/clojure/core$destructure__4413$pb__4415$pmap__4419$fn__4421.class +0 -0
  199. data/lib/clojure/core$destructure__4413$pb__4415$pmap__4419$fn__4427.class +0 -0
  200. data/lib/clojure/core$destructure__4413$pb__4415$pmap__4419$fn__4430.class +0 -0
  201. data/lib/clojure/core$destructure__4413$pb__4415$pmap__4419.class +0 -0
  202. data/lib/clojure/core$destructure__4413$pb__4415$pvec__4416.class +0 -0
  203. data/lib/clojure/core$destructure__4413$pb__4415.class +0 -0
  204. data/lib/clojure/core$destructure__4413$process_entry__4436.class +0 -0
  205. data/lib/clojure/core$destructure__4413.class +0 -0
  206. data/lib/clojure/core$disj__3594.class +0 -0
  207. data/lib/clojure/core$dissoc__3589.class +0 -0
  208. data/lib/clojure/core$distinct_QMARK___4901.class +0 -0
  209. data/lib/clojure/core$distinct__4646$step__4648$fn__4649$fn__4652.class +0 -0
  210. data/lib/clojure/core$distinct__4646$step__4648$fn__4649.class +0 -0
  211. data/lib/clojure/core$distinct__4646$step__4648.class +0 -0
  212. data/lib/clojure/core$distinct__4646.class +0 -0
  213. data/lib/clojure/core$doall__4003.class +0 -0
  214. data/lib/clojure/core$doc__4590.class +0 -0
  215. data/lib/clojure/core$dorun__3998.class +0 -0
  216. data/lib/clojure/core$doseq__3993$step__3995.class +0 -0
  217. data/lib/clojure/core$doseq__3993.class +0 -0
  218. data/lib/clojure/core$dosync__4672.class +0 -0
  219. data/lib/clojure/core$dotimes__4025.class +0 -0
  220. data/lib/clojure/core$doto__4187$fn__4189.class +0 -0
  221. data/lib/clojure/core$doto__4187.class +0 -0
  222. data/lib/clojure/core$double__4077.class +0 -0
  223. data/lib/clojure/core$double_array__4742.class +0 -0
  224. data/lib/clojure/core$doubles__4790.class +0 -0
  225. data/lib/clojure/core$drop__3872$fn__3878.class +0 -0
  226. data/lib/clojure/core$drop__3872$step__3874.class +0 -0
  227. data/lib/clojure/core$drop__3872.class +0 -0
  228. data/lib/clojure/core$drop_last__3882$fn__3885.class +0 -0
  229. data/lib/clojure/core$drop_last__3882.class +0 -0
  230. data/lib/clojure/core$drop_while__3889$fn__3895.class +0 -0
  231. data/lib/clojure/core$drop_while__3889$step__3891.class +0 -0
  232. data/lib/clojure/core$drop_while__3889.class +0 -0
  233. data/lib/clojure/core$empty_QMARK___5084.class +0 -0
  234. data/lib/clojure/core$empty__4721.class +0 -0
  235. data/lib/clojure/core$ensure__3765.class +0 -0
  236. data/lib/clojure/core$enumeration_seq__4935.class +0 -0
  237. data/lib/clojure/core$escape_class_name__5576.class +0 -0
  238. data/lib/clojure/core$eval__3990.class +0 -0
  239. data/lib/clojure/core$eval__4760$fn__4762.class +0 -0
  240. data/lib/clojure/core$eval__4760.class +0 -0
  241. data/lib/clojure/core$eval__4772$fn__4774.class +0 -0
  242. data/lib/clojure/core$eval__4772.class +0 -0
  243. data/lib/clojure/core$eval__4784$fn__4786.class +0 -0
  244. data/lib/clojure/core$eval__4784.class +0 -0
  245. data/lib/clojure/core$eval__4796$fn__4798.class +0 -0
  246. data/lib/clojure/core$eval__4796.class +0 -0
  247. data/lib/clojure/core$even_QMARK___3545.class +0 -0
  248. data/lib/clojure/core$every_QMARK___3806.class +0 -0
  249. data/lib/clojure/core$false_QMARK___3202.class +0 -0
  250. data/lib/clojure/core$ffirst__3125.class +0 -0
  251. data/lib/clojure/core$file_seq__4601$fn__4603.class +0 -0
  252. data/lib/clojure/core$file_seq__4601$fn__4606.class +0 -0
  253. data/lib/clojure/core$file_seq__4601.class +0 -0
  254. data/lib/clojure/core$filter__3845$fn__3851.class +0 -0
  255. data/lib/clojure/core$filter__3845$step__3847.class +0 -0
  256. data/lib/clojure/core$filter__3845.class +0 -0
  257. data/lib/clojure/core$filter_key__4306.class +0 -0
  258. data/lib/clojure/core$find__3599.class +0 -0
  259. data/lib/clojure/core$find_doc__4571.class +0 -0
  260. data/lib/clojure/core$find_field__5583$fn__5585.class +0 -0
  261. data/lib/clojure/core$find_field__5583.class +0 -0
  262. data/lib/clojure/core$find_ns__4309.class +0 -0
  263. data/lib/clojure/core$find_var__3678.class +0 -0
  264. data/lib/clojure/core$first__3115.class +0 -0
  265. data/lib/clojure/core$float_QMARK___4124.class +0 -0
  266. data/lib/clojure/core$float__4071.class +0 -0
  267. data/lib/clojure/core$float_array__4735.class +0 -0
  268. data/lib/clojure/core$floats__4766.class +0 -0
  269. data/lib/clojure/core$flush__4156.class +0 -0
  270. data/lib/clojure/core$fn_QMARK___5099.class +0 -0
  271. data/lib/clojure/core$fn__3113.class +0 -0
  272. data/lib/clojure/core$fn__3288.class +0 -0
  273. data/lib/clojure/core$fn__3301.class +0 -0
  274. data/lib/clojure/core$fn__3329.class +0 -0
  275. data/lib/clojure/core$fn__3338.class +0 -0
  276. data/lib/clojure/core$fn__3347.class +0 -0
  277. data/lib/clojure/core$fn__3355.class +0 -0
  278. data/lib/clojure/core$fn__3363.class +0 -0
  279. data/lib/clojure/core$fn__3371.class +0 -0
  280. data/lib/clojure/core$fn__3379.class +0 -0
  281. data/lib/clojure/core$fn__3387.class +0 -0
  282. data/lib/clojure/core$fn__3395.class +0 -0
  283. data/lib/clojure/core$fn__3413.class +0 -0
  284. data/lib/clojure/core$fn__3419.class +0 -0
  285. data/lib/clojure/core$fn__3425.class +0 -0
  286. data/lib/clojure/core$fn__3431.class +0 -0
  287. data/lib/clojure/core$fn__3437.class +0 -0
  288. data/lib/clojure/core$fn__3443.class +0 -0
  289. data/lib/clojure/core$fn__3449.class +0 -0
  290. data/lib/clojure/core$fn__3455.class +0 -0
  291. data/lib/clojure/core$fn__3461.class +0 -0
  292. data/lib/clojure/core$fn__3467.class +0 -0
  293. data/lib/clojure/core$fn__3473.class +0 -0
  294. data/lib/clojure/core$fn__3479.class +0 -0
  295. data/lib/clojure/core$fn__3485.class +0 -0
  296. data/lib/clojure/core$fn__3500.class +0 -0
  297. data/lib/clojure/core$fn__3506.class +0 -0
  298. data/lib/clojure/core$fn__3512.class +0 -0
  299. data/lib/clojure/core$fn__3518.class +0 -0
  300. data/lib/clojure/core$fn__4050.class +0 -0
  301. data/lib/clojure/core$fn__4056.class +0 -0
  302. data/lib/clojure/core$fn__4062.class +0 -0
  303. data/lib/clojure/core$fn__4068.class +0 -0
  304. data/lib/clojure/core$fn__4074.class +0 -0
  305. data/lib/clojure/core$fn__4080.class +0 -0
  306. data/lib/clojure/core$fn__4086.class +0 -0
  307. data/lib/clojure/core$fn__4092.class +0 -0
  308. data/lib/clojure/core$fn__4098.class +0 -0
  309. data/lib/clojure/core$fn__4139.class +0 -0
  310. data/lib/clojure/core$fn__4142.class +0 -0
  311. data/lib/clojure/core$fn__4202.class +0 -0
  312. data/lib/clojure/core$fn__4208.class +0 -0
  313. data/lib/clojure/core$fn__4214.class +0 -0
  314. data/lib/clojure/core$fn__4221.class +0 -0
  315. data/lib/clojure/core$fn__4443$psig__4445.class +0 -0
  316. data/lib/clojure/core$fn__4443.class +0 -0
  317. data/lib/clojure/core$fn__4732.class +0 -0
  318. data/lib/clojure/core$fn__4739.class +0 -0
  319. data/lib/clojure/core$fn__4746.class +0 -0
  320. data/lib/clojure/core$fn__4753.class +0 -0
  321. data/lib/clojure/core$fn__4769.class +0 -0
  322. data/lib/clojure/core$fn__4781.class +0 -0
  323. data/lib/clojure/core$fn__4793.class +0 -0
  324. data/lib/clojure/core$fn__4805.class +0 -0
  325. data/lib/clojure/core$fn__4976.class +0 -0
  326. data/lib/clojure/core$fn__4980.class +0 -0
  327. data/lib/clojure/core$fn__4984.class +0 -0
  328. data/lib/clojure/core$fn__5379$fn__5381.class +0 -0
  329. data/lib/clojure/core$fn__5379.class +0 -0
  330. data/lib/clojure/core$fn__5385.class +0 -0
  331. data/lib/clojure/core$fn__5388.class +0 -0
  332. data/lib/clojure/core$fn__5394.class +0 -0
  333. data/lib/clojure/core$fn__5397.class +0 -0
  334. data/lib/clojure/core$fn__5400.class +0 -0
  335. data/lib/clojure/core$fn__5403.class +0 -0
  336. data/lib/clojure/core$fn__5406$fn__5408.class +0 -0
  337. data/lib/clojure/core$fn__5406.class +0 -0
  338. data/lib/clojure/core$fn__5412$fn__5414.class +0 -0
  339. data/lib/clojure/core$fn__5412.class +0 -0
  340. data/lib/clojure/core$fn__5418.class +0 -0
  341. data/lib/clojure/core$fn__5421.class +0 -0
  342. data/lib/clojure/core$fn__5427.class +0 -0
  343. data/lib/clojure/core$fn__5430.class +0 -0
  344. data/lib/clojure/core$fn__5433.class +0 -0
  345. data/lib/clojure/core$fn__5436.class +0 -0
  346. data/lib/clojure/core$fn__5439.class +0 -0
  347. data/lib/clojure/core$fn__5442.class +0 -0
  348. data/lib/clojure/core$fn__5445.class +0 -0
  349. data/lib/clojure/core$fn__5448.class +0 -0
  350. data/lib/clojure/core$fn__5453$fn__5455.class +0 -0
  351. data/lib/clojure/core$fn__5453.class +0 -0
  352. data/lib/clojure/core$fn__5459.class +0 -0
  353. data/lib/clojure/core$fn__5462.class +0 -0
  354. data/lib/clojure/core$fn__5467.class +0 -0
  355. data/lib/clojure/core$fn__5470.class +0 -0
  356. data/lib/clojure/core$fn__5479.class +0 -0
  357. data/lib/clojure/core$fn__5484$fn__5486.class +0 -0
  358. data/lib/clojure/core$fn__5484.class +0 -0
  359. data/lib/clojure/core$fn__5490.class +0 -0
  360. data/lib/clojure/core$fn__5493.class +0 -0
  361. data/lib/clojure/core$fn__5496.class +0 -0
  362. data/lib/clojure/core$fn__5500.class +0 -0
  363. data/lib/clojure/core$fn__5503.class +0 -0
  364. data/lib/clojure/core$fn__5506.class +0 -0
  365. data/lib/clojure/core$fn__5509.class +0 -0
  366. data/lib/clojure/core$fn__5512.class +0 -0
  367. data/lib/clojure/core$fn__5515.class +0 -0
  368. data/lib/clojure/core$fn__5518.class +0 -0
  369. data/lib/clojure/core$fn__5521.class +0 -0
  370. data/lib/clojure/core$fn__5524.class +0 -0
  371. data/lib/clojure/core$fn__5527.class +0 -0
  372. data/lib/clojure/core$fn__5530.class +0 -0
  373. data/lib/clojure/core$fn__5533.class +0 -0
  374. data/lib/clojure/core$fn__5536.class +0 -0
  375. data/lib/clojure/core$fn__5544.class +0 -0
  376. data/lib/clojure/core$fn__5547.class +0 -0
  377. data/lib/clojure/core$fn__5550.class +0 -0
  378. data/lib/clojure/core$fn__5774$prop__5777.class +0 -0
  379. data/lib/clojure/core$fn__5774.class +0 -0
  380. data/lib/clojure/core$fnext__3129.class +0 -0
  381. data/lib/clojure/core$for__4475$emit_bind__4489$do_mod__4495.class +0 -0
  382. data/lib/clojure/core$for__4475$emit_bind__4489.class +0 -0
  383. data/lib/clojure/core$for__4475$err__4485.class +0 -0
  384. data/lib/clojure/core$for__4475$to_groups__4477$fn__4480.class +0 -0
  385. data/lib/clojure/core$for__4475$to_groups__4477.class +0 -0
  386. data/lib/clojure/core$for__4475.class +0 -0
  387. data/lib/clojure/core$force__3281.class +0 -0
  388. data/lib/clojure/core$format__4938.class +0 -0
  389. data/lib/clojure/core$future__5722.class +0 -0
  390. data/lib/clojure/core$future_call__5702$fn__5704.class +0 -0
  391. data/lib/clojure/core$future_call__5702$fn__5707.class +0 -0
  392. data/lib/clojure/core$future_call__5702$fn__5710.class +0 -0
  393. data/lib/clojure/core$future_call__5702$fn__5713.class +0 -0
  394. data/lib/clojure/core$future_call__5702$fn__5717.class +0 -0
  395. data/lib/clojure/core$future_call__5702.class +0 -0
  396. data/lib/clojure/core$gen_class__5679.class +0 -0
  397. data/lib/clojure/core$gen_interface__5698.class +0 -0
  398. data/lib/clojure/core$generate_class__5596$arg_types__5608.class +0 -0
  399. data/lib/clojure/core$generate_class__5596$emit_forwarding_method__5642.class +0 -0
  400. data/lib/clojure/core$generate_class__5596$emit_get_var__5636.class +0 -0
  401. data/lib/clojure/core$generate_class__5596$emit_unsupported__5639.class +0 -0
  402. data/lib/clojure/core$generate_class__5596$fn__5614.class +0 -0
  403. data/lib/clojure/core$generate_class__5596$fn__5619.class +0 -0
  404. data/lib/clojure/core$generate_class__5596$fn__5624.class +0 -0
  405. data/lib/clojure/core$generate_class__5596$fn__5629$fn__5632.class +0 -0
  406. data/lib/clojure/core$generate_class__5596$fn__5629.class +0 -0
  407. data/lib/clojure/core$generate_class__5596$fn__5651.class +0 -0
  408. data/lib/clojure/core$generate_class__5596$fn__5654.class +0 -0
  409. data/lib/clojure/core$generate_class__5596$fn__5657.class +0 -0
  410. data/lib/clojure/core$generate_class__5596$fn__5664.class +0 -0
  411. data/lib/clojure/core$generate_class__5596$iname__5599.class +0 -0
  412. data/lib/clojure/core$generate_class__5596$to_types__5605.class +0 -0
  413. data/lib/clojure/core$generate_class__5596$totype__5602.class +0 -0
  414. data/lib/clojure/core$generate_class__5596$var_name__5611.class +0 -0
  415. data/lib/clojure/core$generate_class__5596.class +0 -0
  416. data/lib/clojure/core$generate_interface__5689$fn__5692.class +0 -0
  417. data/lib/clojure/core$generate_interface__5689.class +0 -0
  418. data/lib/clojure/core$generate_proxy__5188$fn__5209$fn__5212.class +0 -0
  419. data/lib/clojure/core$generate_proxy__5188$fn__5209.class +0 -0
  420. data/lib/clojure/core$generate_proxy__5188$fn__5237.class +0 -0
  421. data/lib/clojure/core$generate_proxy__5188$fn__5240.class +0 -0
  422. data/lib/clojure/core$generate_proxy__5188$fn__5247.class +0 -0
  423. data/lib/clojure/core$generate_proxy__5188$fn__5251.class +0 -0
  424. data/lib/clojure/core$generate_proxy__5188$gen_bridge__5199.class +0 -0
  425. data/lib/clojure/core$generate_proxy__5188$gen_method__5203.class +0 -0
  426. data/lib/clojure/core$generate_proxy__5188$iname__5190.class +0 -0
  427. data/lib/clojure/core$generate_proxy__5188$iter__5221__5225$fn__5226$iter__5223__5228$fn__5229.class +0 -0
  428. data/lib/clojure/core$generate_proxy__5188$iter__5221__5225$fn__5226$iter__5223__5228.class +0 -0
  429. data/lib/clojure/core$generate_proxy__5188$iter__5221__5225$fn__5226.class +0 -0
  430. data/lib/clojure/core$generate_proxy__5188$iter__5221__5225.class +0 -0
  431. data/lib/clojure/core$generate_proxy__5188$to_types__5196.class +0 -0
  432. data/lib/clojure/core$generate_proxy__5188$totype__5193.class +0 -0
  433. data/lib/clojure/core$generate_proxy__5188.class +0 -0
  434. data/lib/clojure/core$gensym__3233.class +0 -0
  435. data/lib/clojure/core$get__3585.class +0 -0
  436. data/lib/clojure/core$get_in__5071.class +0 -0
  437. data/lib/clojure/core$get_method__3653.class +0 -0
  438. data/lib/clojure/core$get_proxy_class__5259.class +0 -0
  439. data/lib/clojure/core$get_super_and_interfaces__5256.class +0 -0
  440. data/lib/clojure/core$get_validator__3747.class +0 -0
  441. data/lib/clojure/core$group_by_sig__5170$fn__5173.class +0 -0
  442. data/lib/clojure/core$group_by_sig__5170.class +0 -0
  443. data/lib/clojure/core$hash__4710.class +0 -0
  444. data/lib/clojure/core$hash_map__3173.class +0 -0
  445. data/lib/clojure/core$hash_set__3177.class +0 -0
  446. data/lib/clojure/core$identity__3566.class +0 -0
  447. data/lib/clojure/core$if_let__3663.class +0 -0
  448. data/lib/clojure/core$if_not__3284.class +0 -0
  449. data/lib/clojure/core$ifn_QMARK___5096.class +0 -0
  450. data/lib/clojure/core$import__4028.class +0 -0
  451. data/lib/clojure/core$inc__3416.class +0 -0
  452. data/lib/clojure/core$init_proxy__5268.class +0 -0
  453. data/lib/clojure/core$instance_QMARK___3135.class +0 -0
  454. data/lib/clojure/core$int__4059.class +0 -0
  455. data/lib/clojure/core$int_array__4749.class +0 -0
  456. data/lib/clojure/core$integer_QMARK___4107.class +0 -0
  457. data/lib/clojure/core$interleave__4383.class +0 -0
  458. data/lib/clojure/core$intern__5131.class +0 -0
  459. data/lib/clojure/core$interpose__4713.class +0 -0
  460. data/lib/clojure/core$into__4037.class +0 -0
  461. data/lib/clojure/core$into_array__4033.class +0 -0
  462. data/lib/clojure/core$ints__4778.class +0 -0
  463. data/lib/clojure/core$io_BANG___3771.class +0 -0
  464. data/lib/clojure/core$isa_QMARK___4843$fn__4846.class +0 -0
  465. data/lib/clojure/core$isa_QMARK___4843.class +0 -0
  466. data/lib/clojure/core$iterate__3922$fn__3924.class +0 -0
  467. data/lib/clojure/core$iterate__3922.class +0 -0
  468. data/lib/clojure/core$iterator_seq__4932.class +0 -0
  469. data/lib/clojure/core$key__3611.class +0 -0
  470. data/lib/clojure/core$keys__3605.class +0 -0
  471. data/lib/clojure/core$keyword_QMARK___3222.class +0 -0
  472. data/lib/clojure/core$keyword__3229.class +0 -0
  473. data/lib/clojure/core$last__3154.class +0 -0
  474. data/lib/clojure/core$lazy_cat__4466$fn__4468.class +0 -0
  475. data/lib/clojure/core$lazy_cat__4466.class +0 -0
  476. data/lib/clojure/core$lazy_seq__3252.class +0 -0
  477. data/lib/clojure/core$let__3109.class +0 -0
  478. data/lib/clojure/core$let__4440.class +0 -0
  479. data/lib/clojure/core$letfn__5768$fn__5770.class +0 -0
  480. data/lib/clojure/core$letfn__5768.class +0 -0
  481. data/lib/clojure/core$libspec_QMARK___4995.class +0 -0
  482. data/lib/clojure/core$line_seq__3959$fn__3961.class +0 -0
  483. data/lib/clojure/core$line_seq__3959.class +0 -0
  484. data/lib/clojure/core$list_QMARK___5090.class +0 -0
  485. data/lib/clojure/core$list_STAR___3249.class +0 -0
  486. data/lib/clojure/core$load__5058$fn__5061.class +0 -0
  487. data/lib/clojure/core$load__5058.class +0 -0
  488. data/lib/clojure/core$load_all__5019$fn__5021$fn__5023.class +0 -0
  489. data/lib/clojure/core$load_all__5019$fn__5021$fn__5026.class +0 -0
  490. data/lib/clojure/core$load_all__5019$fn__5021.class +0 -0
  491. data/lib/clojure/core$load_all__5019.class +0 -0
  492. data/lib/clojure/core$load_lib__5031.class +0 -0
  493. data/lib/clojure/core$load_libs__5043.class +0 -0
  494. data/lib/clojure/core$load_one__5010$fn__5012.class +0 -0
  495. data/lib/clojure/core$load_one__5010.class +0 -0
  496. data/lib/clojure/core$load_reader__4297.class +0 -0
  497. data/lib/clojure/core$load_string__4300.class +0 -0
  498. data/lib/clojure/core$loaded_libs__5055.class +0 -0
  499. data/lib/clojure/core$locking__3627.class +0 -0
  500. data/lib/clojure/core$long__4065.class +0 -0
  501. data/lib/clojure/core$long_array__4756.class +0 -0
  502. data/lib/clojure/core$longs__4802.class +0 -0
  503. data/lib/clojure/core$loop__3111.class +0 -0
  504. data/lib/clojure/core$loop__4450$fn__4452.class +0 -0
  505. data/lib/clojure/core$loop__4450$fn__4456.class +0 -0
  506. data/lib/clojure/core$loop__4450.class +0 -0
  507. data/lib/clojure/core$macroexpand_1__4276.class +0 -0
  508. data/lib/clojure/core$macroexpand__4279.class +0 -0
  509. data/lib/clojure/core$make_array__4268.class +0 -0
  510. data/lib/clojure/core$make_hierarchy__4830.class +0 -0
  511. data/lib/clojure/core$map_QMARK___3141.class +0 -0
  512. data/lib/clojure/core$map__3815$fn__3817.class +0 -0
  513. data/lib/clojure/core$map__3815$fn__3822.class +0 -0
  514. data/lib/clojure/core$map__3815$fn__3827.class +0 -0
  515. data/lib/clojure/core$map__3815$fn__3838.class +0 -0
  516. data/lib/clojure/core$map__3815$step__3833$fn__3834.class +0 -0
  517. data/lib/clojure/core$map__3815$step__3833.class +0 -0
  518. data/lib/clojure/core$map__3815.class +0 -0
  519. data/lib/clojure/core$mapcat__3842.class +0 -0
  520. data/lib/clojure/core$max__3403.class +0 -0
  521. data/lib/clojure/core$max_key__4628$fn__4632.class +0 -0
  522. data/lib/clojure/core$max_key__4628.class +0 -0
  523. data/lib/clojure/core$memfn__4194.class +0 -0
  524. data/lib/clojure/core$memoize__5138$fn__5140.class +0 -0
  525. data/lib/clojure/core$memoize__5138.class +0 -0
  526. data/lib/clojure/core$merge__3938$fn__3940.class +0 -0
  527. data/lib/clojure/core$merge__3938.class +0 -0
  528. data/lib/clojure/core$merge_with__3945$merge2__3950.class +0 -0
  529. data/lib/clojure/core$merge_with__3945$merge_entry__3947.class +0 -0
  530. data/lib/clojure/core$merge_with__3945.class +0 -0
  531. data/lib/clojure/core$meta__3150.class +0 -0
  532. data/lib/clojure/core$method_sig__5156.class +0 -0
  533. data/lib/clojure/core$methods__3650.class +0 -0
  534. data/lib/clojure/core$min__3408.class +0 -0
  535. data/lib/clojure/core$min_key__4638$fn__4642.class +0 -0
  536. data/lib/clojure/core$min_key__4638.class +0 -0
  537. data/lib/clojure/core$mod__4114.class +0 -0
  538. data/lib/clojure/core$most_specific__5160$fn__5162$fn__5164.class +0 -0
  539. data/lib/clojure/core$most_specific__5160$fn__5162.class +0 -0
  540. data/lib/clojure/core$most_specific__5160.class +0 -0
  541. data/lib/clojure/core$name__3620.class +0 -0
  542. data/lib/clojure/core$namespace__3623.class +0 -0
  543. data/lib/clojure/core$neg_QMARK___3482.class +0 -0
  544. data/lib/clojure/core$newline__4153.class +0 -0
  545. data/lib/clojure/core$next__3117.class +0 -0
  546. data/lib/clojure/core$nfirst__3127.class +0 -0
  547. data/lib/clojure/core$nil_QMARK___3199.class +0 -0
  548. data/lib/clojure/core$nnext__3131.class +0 -0
  549. data/lib/clojure/core$non_private_methods__5553$fn__5556.class +0 -0
  550. data/lib/clojure/core$non_private_methods__5553.class +0 -0
  551. data/lib/clojure/core$not_EQ___3296.class +0 -0
  552. data/lib/clojure/core$not__3208.class +0 -0
  553. data/lib/clojure/core$not_empty__4833.class +0 -0
  554. data/lib/clojure/core$ns__4948$fn__4958.class +0 -0
  555. data/lib/clojure/core$ns__4948$fn__4961.class +0 -0
  556. data/lib/clojure/core$ns__4948$fn__4964.class +0 -0
  557. data/lib/clojure/core$ns__4948$process_reference__4951$fn__4954.class +0 -0
  558. data/lib/clojure/core$ns__4948$process_reference__4951.class +0 -0
  559. data/lib/clojure/core$ns__4948.class +0 -0
  560. data/lib/clojure/core$ns_aliases__4370.class +0 -0
  561. data/lib/clojure/core$ns_imports__4342.class +0 -0
  562. data/lib/clojure/core$ns_interns__4360$fn__4362.class +0 -0
  563. data/lib/clojure/core$ns_interns__4360.class +0 -0
  564. data/lib/clojure/core$ns_map__4328.class +0 -0
  565. data/lib/clojure/core$ns_name__4325.class +0 -0
  566. data/lib/clojure/core$ns_publics__4334$fn__4336.class +0 -0
  567. data/lib/clojure/core$ns_publics__4334.class +0 -0
  568. data/lib/clojure/core$ns_refers__4353$fn__4355.class +0 -0
  569. data/lib/clojure/core$ns_refers__4353.class +0 -0
  570. data/lib/clojure/core$ns_resolve__4395.class +0 -0
  571. data/lib/clojure/core$ns_unalias__4373.class +0 -0
  572. data/lib/clojure/core$ns_unmap__4331.class +0 -0
  573. data/lib/clojure/core$nth__3578.class +0 -0
  574. data/lib/clojure/core$nthnext__4405.class +0 -0
  575. data/lib/clojure/core$num__4053.class +0 -0
  576. data/lib/clojure/core$number_QMARK___4104.class +0 -0
  577. data/lib/clojure/core$odd_QMARK___3548.class +0 -0
  578. data/lib/clojure/core$or__3314.class +0 -0
  579. data/lib/clojure/core$overload_name__5579.class +0 -0
  580. data/lib/clojure/core$parents__4861.class +0 -0
  581. data/lib/clojure/core$partial__3781$fn__3783.class +0 -0
  582. data/lib/clojure/core$partial__3781$fn__3787.class +0 -0
  583. data/lib/clojure/core$partial__3781$fn__3791.class +0 -0
  584. data/lib/clojure/core$partial__3781$fn__3795.class +0 -0
  585. data/lib/clojure/core$partial__3781.class +0 -0
  586. data/lib/clojure/core$partition__3982$fn__3985.class +0 -0
  587. data/lib/clojure/core$partition__3982.class +0 -0
  588. data/lib/clojure/core$pcalls__5754$fn__5756.class +0 -0
  589. data/lib/clojure/core$pcalls__5754.class +0 -0
  590. data/lib/clojure/core$peek__3572.class +0 -0
  591. data/lib/clojure/core$pmap__5727$fn__5729$fn__5731.class +0 -0
  592. data/lib/clojure/core$pmap__5727$fn__5729.class +0 -0
  593. data/lib/clojure/core$pmap__5727$fn__5749.class +0 -0
  594. data/lib/clojure/core$pmap__5727$step__5736$fn__5738.class +0 -0
  595. data/lib/clojure/core$pmap__5727$step__5736.class +0 -0
  596. data/lib/clojure/core$pmap__5727$step__5744$fn__5745.class +0 -0
  597. data/lib/clojure/core$pmap__5727$step__5744.class +0 -0
  598. data/lib/clojure/core$pmap__5727.class +0 -0
  599. data/lib/clojure/core$pop__3575.class +0 -0
  600. data/lib/clojure/core$pos_QMARK___3476.class +0 -0
  601. data/lib/clojure/core$pr__4148.class +0 -0
  602. data/lib/clojure/core$pr_on__4145.class +0 -0
  603. data/lib/clojure/core$pr_str__4512.class +0 -0
  604. data/lib/clojure/core$prefer_method__3647.class +0 -0
  605. data/lib/clojure/core$prefers__3656.class +0 -0
  606. data/lib/clojure/core$prependss__5001.class +0 -0
  607. data/lib/clojure/core$print__4162.class +0 -0
  608. data/lib/clojure/core$print_ctor__5391.class +0 -0
  609. data/lib/clojure/core$print_doc__4568.class +0 -0
  610. data/lib/clojure/core$print_map__5473$fn__5475.class +0 -0
  611. data/lib/clojure/core$print_map__5473.class +0 -0
  612. data/lib/clojure/core$print_meta__5370.class +0 -0
  613. data/lib/clojure/core$print_namespace_doc__4587.class +0 -0
  614. data/lib/clojure/core$print_sequential__5354.class +0 -0
  615. data/lib/clojure/core$print_simple__5424.class +0 -0
  616. data/lib/clojure/core$print_special_doc__4584.class +0 -0
  617. data/lib/clojure/core$print_str__4520.class +0 -0
  618. data/lib/clojure/core$printf__4941.class +0 -0
  619. data/lib/clojure/core$println__4165.class +0 -0
  620. data/lib/clojure/core$println_str__4524.class +0 -0
  621. data/lib/clojure/core$prn__4159.class +0 -0
  622. data/lib/clojure/core$prn_str__4516.class +0 -0
  623. data/lib/clojure/core$proxy__5279$fn__5282.class +0 -0
  624. data/lib/clojure/core$proxy__5279$fn__5287$fn__5291.class +0 -0
  625. data/lib/clojure/core$proxy__5279$fn__5287.class +0 -0
  626. data/lib/clojure/core$proxy__5279.class +0 -0
  627. data/lib/clojure/core$proxy_call_with_super__5297.class +0 -0
  628. data/lib/clojure/core$proxy_mappings__5274.class +0 -0
  629. data/lib/clojure/core$proxy_name__5179$fn__5181.class +0 -0
  630. data/lib/clojure/core$proxy_name__5179.class +0 -0
  631. data/lib/clojure/core$proxy_super__5300.class +0 -0
  632. data/lib/clojure/core$pvalues__5761$fn__5763.class +0 -0
  633. data/lib/clojure/core$pvalues__5761.class +0 -0
  634. data/lib/clojure/core$quot__3491.class +0 -0
  635. data/lib/clojure/core$rand__4558.class +0 -0
  636. data/lib/clojure/core$rand_int__4562.class +0 -0
  637. data/lib/clojure/core$range__3928.class +0 -0
  638. data/lib/clojure/core$ratio_QMARK___4118.class +0 -0
  639. data/lib/clojure/core$rational_QMARK___4128.class +0 -0
  640. data/lib/clojure/core$rationalize__3497.class +0 -0
  641. data/lib/clojure/core$re_find__4554.class +0 -0
  642. data/lib/clojure/core$re_groups__4540.class +0 -0
  643. data/lib/clojure/core$re_matcher__4537.class +0 -0
  644. data/lib/clojure/core$re_matches__4551.class +0 -0
  645. data/lib/clojure/core$re_pattern__4534.class +0 -0
  646. data/lib/clojure/core$re_seq__4543$step__4545$fn__4546.class +0 -0
  647. data/lib/clojure/core$re_seq__4543$step__4545.class +0 -0
  648. data/lib/clojure/core$re_seq__4543.class +0 -0
  649. data/lib/clojure/core$read__4168.class +0 -0
  650. data/lib/clojure/core$read_line__4174.class +0 -0
  651. data/lib/clojure/core$read_string__4177.class +0 -0
  652. data/lib/clojure/core$reduce__3319$fn__3322.class +0 -0
  653. data/lib/clojure/core$reduce__3319.class +0 -0
  654. data/lib/clojure/core$ref__3721.class +0 -0
  655. data/lib/clojure/core$ref_set__3762.class +0 -0
  656. data/lib/clojure/core$refer__4345.class +0 -0
  657. data/lib/clojure/core$refer_clojure__4969.class +0 -0
  658. data/lib/clojure/core$release_pending_sends__3694.class +0 -0
  659. data/lib/clojure/core$rem__3494.class +0 -0
  660. data/lib/clojure/core$remove__3855.class +0 -0
  661. data/lib/clojure/core$remove_method__3644.class +0 -0
  662. data/lib/clojure/core$remove_ns__4315.class +0 -0
  663. data/lib/clojure/core$remove_watch__3700.class +0 -0
  664. data/lib/clojure/core$remove_watcher__3709.class +0 -0
  665. data/lib/clojure/core$repeat__3912$fn__3914.class +0 -0
  666. data/lib/clojure/core$repeat__3912.class +0 -0
  667. data/lib/clojure/core$repeatedly__4701$fn__4703.class +0 -0
  668. data/lib/clojure/core$repeatedly__4701.class +0 -0
  669. data/lib/clojure/core$replace__4661$fn__4663.class +0 -0
  670. data/lib/clojure/core$replace__4661$fn__4667.class +0 -0
  671. data/lib/clojure/core$replace__4661.class +0 -0
  672. data/lib/clojure/core$replicate__3919.class +0 -0
  673. data/lib/clojure/core$require__5049.class +0 -0
  674. data/lib/clojure/core$reset_BANG___3741.class +0 -0
  675. data/lib/clojure/core$reset_meta_BANG___3753.class +0 -0
  676. data/lib/clojure/core$resolve__4398.class +0 -0
  677. data/lib/clojure/core$rest__3119.class +0 -0
  678. data/lib/clojure/core$resultset_seq__4911$fn__4913.class +0 -0
  679. data/lib/clojure/core$resultset_seq__4911$fn__4916.class +0 -0
  680. data/lib/clojure/core$resultset_seq__4911$row_values__4919$fn__4921.class +0 -0
  681. data/lib/clojure/core$resultset_seq__4911$row_values__4919.class +0 -0
  682. data/lib/clojure/core$resultset_seq__4911$thisfn__4925$fn__4926.class +0 -0
  683. data/lib/clojure/core$resultset_seq__4911$thisfn__4925.class +0 -0
  684. data/lib/clojure/core$resultset_seq__4911.class +0 -0
  685. data/lib/clojure/core$reverse__3326.class +0 -0
  686. data/lib/clojure/core$reversible_QMARK___5114.class +0 -0
  687. data/lib/clojure/core$root_directory__5007.class +0 -0
  688. data/lib/clojure/core$root_resource__5004.class +0 -0
  689. data/lib/clojure/core$rseq__3617.class +0 -0
  690. data/lib/clojure/core$rsubseq__4693.class +0 -0
  691. data/lib/clojure/core$second__3123.class +0 -0
  692. data/lib/clojure/core$select_keys__3602.class +0 -0
  693. data/lib/clojure/core$send__3688.class +0 -0
  694. data/lib/clojure/core$send_off__3691.class +0 -0
  695. data/lib/clojure/core$seq_QMARK___3137.class +0 -0
  696. data/lib/clojure/core$seq__3133.class +0 -0
  697. data/lib/clojure/core$seque__4808$drain__4818$fn__4819.class +0 -0
  698. data/lib/clojure/core$seque__4808$drain__4818.class +0 -0
  699. data/lib/clojure/core$seque__4808$fill__4811.class +0 -0
  700. data/lib/clojure/core$seque__4808.class +0 -0
  701. data/lib/clojure/core$sequence__3802.class +0 -0
  702. data/lib/clojure/core$sequential_QMARK___5105.class +0 -0
  703. data/lib/clojure/core$set_QMARK___5093.class +0 -0
  704. data/lib/clojure/core$set__4303.class +0 -0
  705. data/lib/clojure/core$set_validator_BANG___3744.class +0 -0
  706. data/lib/clojure/core$setup_reference__3681.class +0 -0
  707. data/lib/clojure/core$short__4083.class +0 -0
  708. data/lib/clojure/core$shutdown_agents__3718.class +0 -0
  709. data/lib/clojure/core$sigs__3145.class +0 -0
  710. data/lib/clojure/core$slurp__4619.class +0 -0
  711. data/lib/clojure/core$some__3810.class +0 -0
  712. data/lib/clojure/core$sort__3971.class +0 -0
  713. data/lib/clojure/core$sort_by__3975$fn__3978.class +0 -0
  714. data/lib/clojure/core$sort_by__3975.class +0 -0
  715. data/lib/clojure/core$sorted_QMARK___5108.class +0 -0
  716. data/lib/clojure/core$sorted_map__3181.class +0 -0
  717. data/lib/clojure/core$sorted_map_by__3187.class +0 -0
  718. data/lib/clojure/core$sorted_set__3184.class +0 -0
  719. data/lib/clojure/core$special_form_anchor__4578.class +0 -0
  720. data/lib/clojure/core$special_symbol_QMARK___4613.class +0 -0
  721. data/lib/clojure/core$split_at__3906.class +0 -0
  722. data/lib/clojure/core$split_with__3909.class +0 -0
  723. data/lib/clojure/core$spread__3240.class +0 -0
  724. data/lib/clojure/core$str__3211$fn__3215.class +0 -0
  725. data/lib/clojure/core$str__3211.class +0 -0
  726. data/lib/clojure/core$stream_QMARK___3799.class +0 -0
  727. data/lib/clojure/core$string_QMARK___3139.class +0 -0
  728. data/lib/clojure/core$struct__4291.class +0 -0
  729. data/lib/clojure/core$struct_map__4288.class +0 -0
  730. data/lib/clojure/core$subs__4622.class +0 -0
  731. data/lib/clojure/core$subseq__4685.class +0 -0
  732. data/lib/clojure/core$subvec__4180.class +0 -0
  733. data/lib/clojure/core$supers__4839.class +0 -0
  734. data/lib/clojure/core$swap_BANG___3732.class +0 -0
  735. data/lib/clojure/core$symbol_QMARK___3219.class +0 -0
  736. data/lib/clojure/core$symbol__3225.class +0 -0
  737. data/lib/clojure/core$sync__3768.class +0 -0
  738. data/lib/clojure/core$syntax_symbol_anchor__4581.class +0 -0
  739. data/lib/clojure/core$take__3858$fn__3860.class +0 -0
  740. data/lib/clojure/core$take__3858.class +0 -0
  741. data/lib/clojure/core$take_nth__4376$fn__4378.class +0 -0
  742. data/lib/clojure/core$take_nth__4376.class +0 -0
  743. data/lib/clojure/core$take_while__3865$fn__3867.class +0 -0
  744. data/lib/clojure/core$take_while__3865.class +0 -0
  745. data/lib/clojure/core$test__4531.class +0 -0
  746. data/lib/clojure/core$the_class__5590.class +0 -0
  747. data/lib/clojure/core$the_ns__4321.class +0 -0
  748. data/lib/clojure/core$throw_if__4989$boring_QMARK___4991.class +0 -0
  749. data/lib/clojure/core$throw_if__4989.class +0 -0
  750. data/lib/clojure/core$time__4199.class +0 -0
  751. data/lib/clojure/core$to_array_2d__4273.class +0 -0
  752. data/lib/clojure/core$to_array__3163.class +0 -0
  753. data/lib/clojure/core$trampoline__5124$fn__5127.class +0 -0
  754. data/lib/clojure/core$trampoline__5124.class +0 -0
  755. data/lib/clojure/core$tree_seq__4593$walk__4595$fn__4596.class +0 -0
  756. data/lib/clojure/core$tree_seq__4593$walk__4595.class +0 -0
  757. data/lib/clojure/core$tree_seq__4593.class +0 -0
  758. data/lib/clojure/core$true_QMARK___3205.class +0 -0
  759. data/lib/clojure/core$type__4046.class +0 -0
  760. data/lib/clojure/core$unchecked_add__3446.class +0 -0
  761. data/lib/clojure/core$unchecked_dec__3434.class +0 -0
  762. data/lib/clojure/core$unchecked_divide__3464.class +0 -0
  763. data/lib/clojure/core$unchecked_inc__3428.class +0 -0
  764. data/lib/clojure/core$unchecked_multiply__3458.class +0 -0
  765. data/lib/clojure/core$unchecked_negate__3440.class +0 -0
  766. data/lib/clojure/core$unchecked_remainder__3470.class +0 -0
  767. data/lib/clojure/core$unchecked_subtract__3452.class +0 -0
  768. data/lib/clojure/core$underive__4891$tf__4894$fn__4896.class +0 -0
  769. data/lib/clojure/core$underive__4891$tf__4894.class +0 -0
  770. data/lib/clojure/core$underive__4891.class +0 -0
  771. data/lib/clojure/core$update_in__5080.class +0 -0
  772. data/lib/clojure/core$update_proxy__5271.class +0 -0
  773. data/lib/clojure/core$use__5052.class +0 -0
  774. data/lib/clojure/core$val__3614.class +0 -0
  775. data/lib/clojure/core$vals__3608.class +0 -0
  776. data/lib/clojure/core$var_QMARK___4616.class +0 -0
  777. data/lib/clojure/core$var_get__4386.class +0 -0
  778. data/lib/clojure/core$var_set__4389.class +0 -0
  779. data/lib/clojure/core$vary_meta__3246.class +0 -0
  780. data/lib/clojure/core$vec__3170.class +0 -0
  781. data/lib/clojure/core$vector_QMARK___3143.class +0 -0
  782. data/lib/clojure/core$vector__3166.class +0 -0
  783. data/lib/clojure/core$when__3193.class +0 -0
  784. data/lib/clojure/core$when_first__4461.class +0 -0
  785. data/lib/clojure/core$when_let__3669.class +0 -0
  786. data/lib/clojure/core$when_not__3196.class +0 -0
  787. data/lib/clojure/core$while__5135.class +0 -0
  788. data/lib/clojure/core$with_in_str__4509.class +0 -0
  789. data/lib/clojure/core$with_local_vars__4392.class +0 -0
  790. data/lib/clojure/core$with_meta__3152.class +0 -0
  791. data/lib/clojure/core$with_open__4184.class +0 -0
  792. data/lib/clojure/core$with_out_str__4505.class +0 -0
  793. data/lib/clojure/core$with_precision__4675.class +0 -0
  794. data/lib/clojure/core$xml_seq__4610.class +0 -0
  795. data/lib/clojure/core$zero_QMARK___3488.class +0 -0
  796. data/lib/clojure/core$zipmap__3955.class +0 -0
  797. data/lib/clojure/core.clj +4121 -0
  798. data/lib/clojure/core__init.class +0 -0
  799. data/lib/clojure/core_print.clj +317 -0
  800. data/lib/clojure/core_print__init.class +0 -0
  801. data/lib/clojure/core_proxy.clj +394 -0
  802. data/lib/clojure/core_proxy__init.class +0 -0
  803. data/lib/clojure/genclass.clj +683 -0
  804. data/lib/clojure/genclass__init.class +0 -0
  805. data/lib/clojure/inspector$atom_QMARK___6181.class +0 -0
  806. data/lib/clojure/inspector$collection_tag__6184.class +0 -0
  807. data/lib/clojure/inspector$fn__6187.class +0 -0
  808. data/lib/clojure/inspector$fn__6190.class +0 -0
  809. data/lib/clojure/inspector$fn__6193.class +0 -0
  810. data/lib/clojure/inspector$fn__6196.class +0 -0
  811. data/lib/clojure/inspector$fn__6199.class +0 -0
  812. data/lib/clojure/inspector$fn__6202.class +0 -0
  813. data/lib/clojure/inspector$fn__6205.class +0 -0
  814. data/lib/clojure/inspector$fn__6208.class +0 -0
  815. data/lib/clojure/inspector$fn__6211.class +0 -0
  816. data/lib/clojure/inspector$fn__6278$fn__6280.class +0 -0
  817. data/lib/clojure/inspector$fn__6278$fn__6283.class +0 -0
  818. data/lib/clojure/inspector$fn__6278.class +0 -0
  819. data/lib/clojure/inspector$fn__6287$fn__6289.class +0 -0
  820. data/lib/clojure/inspector$fn__6287$fn__6292.class +0 -0
  821. data/lib/clojure/inspector$fn__6287.class +0 -0
  822. data/lib/clojure/inspector$fn__6296$fn__6299.class +0 -0
  823. data/lib/clojure/inspector$fn__6296$fn__6303.class +0 -0
  824. data/lib/clojure/inspector$fn__6296$fn__6306.class +0 -0
  825. data/lib/clojure/inspector$fn__6296.class +0 -0
  826. data/lib/clojure/inspector$fn__6324$fn__6326.class +0 -0
  827. data/lib/clojure/inspector$fn__6324$fn__6329.class +0 -0
  828. data/lib/clojure/inspector$fn__6324$fn__6332.class +0 -0
  829. data/lib/clojure/inspector$fn__6324.class +0 -0
  830. data/lib/clojure/inspector$inspect__6337.class +0 -0
  831. data/lib/clojure/inspector$inspect_table__6274.class +0 -0
  832. data/lib/clojure/inspector$inspect_tree__6270.class +0 -0
  833. data/lib/clojure/inspector$list_model__6310$fn__6313.class +0 -0
  834. data/lib/clojure/inspector$list_model__6310$fn__6316.class +0 -0
  835. data/lib/clojure/inspector$list_model__6310$fn__6319.class +0 -0
  836. data/lib/clojure/inspector$list_model__6310.class +0 -0
  837. data/lib/clojure/inspector$old_table_model__6242$fn__6244.class +0 -0
  838. data/lib/clojure/inspector$old_table_model__6242$fn__6247.class +0 -0
  839. data/lib/clojure/inspector$old_table_model__6242$fn__6250.class +0 -0
  840. data/lib/clojure/inspector$old_table_model__6242$fn__6253.class +0 -0
  841. data/lib/clojure/inspector$old_table_model__6242$fn__6256.class +0 -0
  842. data/lib/clojure/inspector$old_table_model__6242$fn__6259.class +0 -0
  843. data/lib/clojure/inspector$old_table_model__6242$fn__6262.class +0 -0
  844. data/lib/clojure/inspector$old_table_model__6242$fn__6265.class +0 -0
  845. data/lib/clojure/inspector$old_table_model__6242.class +0 -0
  846. data/lib/clojure/inspector$tree_model__6214$fn__6216.class +0 -0
  847. data/lib/clojure/inspector$tree_model__6214$fn__6219.class +0 -0
  848. data/lib/clojure/inspector$tree_model__6214$fn__6222.class +0 -0
  849. data/lib/clojure/inspector$tree_model__6214$fn__6225.class +0 -0
  850. data/lib/clojure/inspector$tree_model__6214$fn__6228.class +0 -0
  851. data/lib/clojure/inspector$tree_model__6214$fn__6231.class +0 -0
  852. data/lib/clojure/inspector$tree_model__6214$fn__6234.class +0 -0
  853. data/lib/clojure/inspector$tree_model__6214$fn__6237.class +0 -0
  854. data/lib/clojure/inspector$tree_model__6214.class +0 -0
  855. data/lib/clojure/inspector.clj +180 -0
  856. data/lib/clojure/inspector__init.class +0 -0
  857. data/lib/clojure/lang/AFn.class +0 -0
  858. data/lib/clojure/lang/AFunction.class +0 -0
  859. data/lib/clojure/lang/AMapEntry.class +0 -0
  860. data/lib/clojure/lang/APersistentMap$1.class +0 -0
  861. data/lib/clojure/lang/APersistentMap$2$1.class +0 -0
  862. data/lib/clojure/lang/APersistentMap$2.class +0 -0
  863. data/lib/clojure/lang/APersistentMap$3$1.class +0 -0
  864. data/lib/clojure/lang/APersistentMap$3.class +0 -0
  865. data/lib/clojure/lang/APersistentMap$KeySeq.class +0 -0
  866. data/lib/clojure/lang/APersistentMap$ValSeq.class +0 -0
  867. data/lib/clojure/lang/APersistentMap.class +0 -0
  868. data/lib/clojure/lang/APersistentSet.class +0 -0
  869. data/lib/clojure/lang/APersistentVector$1.class +0 -0
  870. data/lib/clojure/lang/APersistentVector$2.class +0 -0
  871. data/lib/clojure/lang/APersistentVector$RSeq.class +0 -0
  872. data/lib/clojure/lang/APersistentVector$Seq.class +0 -0
  873. data/lib/clojure/lang/APersistentVector$Src.class +0 -0
  874. data/lib/clojure/lang/APersistentVector$SubVector.class +0 -0
  875. data/lib/clojure/lang/APersistentVector.class +0 -0
  876. data/lib/clojure/lang/ARef.class +0 -0
  877. data/lib/clojure/lang/AReference.class +0 -0
  878. data/lib/clojure/lang/ASeq$Src.class +0 -0
  879. data/lib/clojure/lang/ASeq.class +0 -0
  880. data/lib/clojure/lang/Agent$Action.class +0 -0
  881. data/lib/clojure/lang/Agent.class +0 -0
  882. data/lib/clojure/lang/ArraySeq$ArraySeq_double.class +0 -0
  883. data/lib/clojure/lang/ArraySeq$ArraySeq_float.class +0 -0
  884. data/lib/clojure/lang/ArraySeq$ArraySeq_int.class +0 -0
  885. data/lib/clojure/lang/ArraySeq$ArraySeq_long.class +0 -0
  886. data/lib/clojure/lang/ArraySeq.class +0 -0
  887. data/lib/clojure/lang/ArrayStream$ArrayStream_boolean.class +0 -0
  888. data/lib/clojure/lang/ArrayStream$ArrayStream_byte.class +0 -0
  889. data/lib/clojure/lang/ArrayStream$ArrayStream_char.class +0 -0
  890. data/lib/clojure/lang/ArrayStream$ArrayStream_double.class +0 -0
  891. data/lib/clojure/lang/ArrayStream$ArrayStream_float.class +0 -0
  892. data/lib/clojure/lang/ArrayStream$ArrayStream_int.class +0 -0
  893. data/lib/clojure/lang/ArrayStream$ArrayStream_long.class +0 -0
  894. data/lib/clojure/lang/ArrayStream$ArrayStream_short.class +0 -0
  895. data/lib/clojure/lang/ArrayStream.class +0 -0
  896. data/lib/clojure/lang/Associative.class +0 -0
  897. data/lib/clojure/lang/Atom.class +0 -0
  898. data/lib/clojure/lang/Binding.class +0 -0
  899. data/lib/clojure/lang/Box.class +0 -0
  900. data/lib/clojure/lang/Compile.class +0 -0
  901. data/lib/clojure/lang/Compiler$1.class +0 -0
  902. data/lib/clojure/lang/Compiler$AssignExpr$Parser.class +0 -0
  903. data/lib/clojure/lang/Compiler$AssignExpr.class +0 -0
  904. data/lib/clojure/lang/Compiler$AssignableExpr.class +0 -0
  905. data/lib/clojure/lang/Compiler$BindingInit.class +0 -0
  906. data/lib/clojure/lang/Compiler$BodyExpr$Parser.class +0 -0
  907. data/lib/clojure/lang/Compiler$BodyExpr.class +0 -0
  908. data/lib/clojure/lang/Compiler$BooleanExpr.class +0 -0
  909. data/lib/clojure/lang/Compiler$C.class +0 -0
  910. data/lib/clojure/lang/Compiler$CompilerException.class +0 -0
  911. data/lib/clojure/lang/Compiler$ConstantExpr$Parser.class +0 -0
  912. data/lib/clojure/lang/Compiler$ConstantExpr.class +0 -0
  913. data/lib/clojure/lang/Compiler$DefExpr$Parser.class +0 -0
  914. data/lib/clojure/lang/Compiler$DefExpr.class +0 -0
  915. data/lib/clojure/lang/Compiler$EmptyExpr.class +0 -0
  916. data/lib/clojure/lang/Compiler$Expr.class +0 -0
  917. data/lib/clojure/lang/Compiler$FieldExpr.class +0 -0
  918. data/lib/clojure/lang/Compiler$FnExpr.class +0 -0
  919. data/lib/clojure/lang/Compiler$FnLoaderThunk.class +0 -0
  920. data/lib/clojure/lang/Compiler$FnMethod.class +0 -0
  921. data/lib/clojure/lang/Compiler$HostExpr$Parser.class +0 -0
  922. data/lib/clojure/lang/Compiler$HostExpr.class +0 -0
  923. data/lib/clojure/lang/Compiler$IParser.class +0 -0
  924. data/lib/clojure/lang/Compiler$IfExpr$Parser.class +0 -0
  925. data/lib/clojure/lang/Compiler$IfExpr.class +0 -0
  926. data/lib/clojure/lang/Compiler$InstanceFieldExpr.class +0 -0
  927. data/lib/clojure/lang/Compiler$InstanceMethodExpr.class +0 -0
  928. data/lib/clojure/lang/Compiler$InvokeExpr.class +0 -0
  929. data/lib/clojure/lang/Compiler$KeywordExpr.class +0 -0
  930. data/lib/clojure/lang/Compiler$LetExpr$Parser.class +0 -0
  931. data/lib/clojure/lang/Compiler$LetExpr.class +0 -0
  932. data/lib/clojure/lang/Compiler$LetFnExpr$Parser.class +0 -0
  933. data/lib/clojure/lang/Compiler$LetFnExpr.class +0 -0
  934. data/lib/clojure/lang/Compiler$ListExpr.class +0 -0
  935. data/lib/clojure/lang/Compiler$LiteralExpr.class +0 -0
  936. data/lib/clojure/lang/Compiler$LocalBinding.class +0 -0
  937. data/lib/clojure/lang/Compiler$LocalBindingExpr.class +0 -0
  938. data/lib/clojure/lang/Compiler$MapExpr.class +0 -0
  939. data/lib/clojure/lang/Compiler$MaybePrimitiveExpr.class +0 -0
  940. data/lib/clojure/lang/Compiler$MetaExpr.class +0 -0
  941. data/lib/clojure/lang/Compiler$MethodExpr.class +0 -0
  942. data/lib/clojure/lang/Compiler$MonitorEnterExpr$Parser.class +0 -0
  943. data/lib/clojure/lang/Compiler$MonitorEnterExpr.class +0 -0
  944. data/lib/clojure/lang/Compiler$MonitorExitExpr$Parser.class +0 -0
  945. data/lib/clojure/lang/Compiler$MonitorExitExpr.class +0 -0
  946. data/lib/clojure/lang/Compiler$NewExpr$Parser.class +0 -0
  947. data/lib/clojure/lang/Compiler$NewExpr.class +0 -0
  948. data/lib/clojure/lang/Compiler$NilExpr.class +0 -0
  949. data/lib/clojure/lang/Compiler$PSTATE.class +0 -0
  950. data/lib/clojure/lang/Compiler$RecurExpr$Parser.class +0 -0
  951. data/lib/clojure/lang/Compiler$RecurExpr.class +0 -0
  952. data/lib/clojure/lang/Compiler$SetExpr.class +0 -0
  953. data/lib/clojure/lang/Compiler$SourceDebugExtensionAttribute.class +0 -0
  954. data/lib/clojure/lang/Compiler$StaticFieldExpr.class +0 -0
  955. data/lib/clojure/lang/Compiler$StaticMethodExpr.class +0 -0
  956. data/lib/clojure/lang/Compiler$StringExpr.class +0 -0
  957. data/lib/clojure/lang/Compiler$TheVarExpr$Parser.class +0 -0
  958. data/lib/clojure/lang/Compiler$TheVarExpr.class +0 -0
  959. data/lib/clojure/lang/Compiler$ThrowExpr$Parser.class +0 -0
  960. data/lib/clojure/lang/Compiler$ThrowExpr.class +0 -0
  961. data/lib/clojure/lang/Compiler$TryExpr$CatchClause.class +0 -0
  962. data/lib/clojure/lang/Compiler$TryExpr$Parser.class +0 -0
  963. data/lib/clojure/lang/Compiler$TryExpr.class +0 -0
  964. data/lib/clojure/lang/Compiler$UnresolvedVarExpr.class +0 -0
  965. data/lib/clojure/lang/Compiler$UntypedExpr.class +0 -0
  966. data/lib/clojure/lang/Compiler$VarExpr.class +0 -0
  967. data/lib/clojure/lang/Compiler$VectorExpr.class +0 -0
  968. data/lib/clojure/lang/Compiler.class +0 -0
  969. data/lib/clojure/lang/Cons.class +0 -0
  970. data/lib/clojure/lang/Counted.class +0 -0
  971. data/lib/clojure/lang/Delay.class +0 -0
  972. data/lib/clojure/lang/DynamicClassLoader.class +0 -0
  973. data/lib/clojure/lang/EnumerationSeq$State.class +0 -0
  974. data/lib/clojure/lang/EnumerationSeq.class +0 -0
  975. data/lib/clojure/lang/Fn.class +0 -0
  976. data/lib/clojure/lang/IDeref.class +0 -0
  977. data/lib/clojure/lang/IFn.class +0 -0
  978. data/lib/clojure/lang/IMapEntry.class +0 -0
  979. data/lib/clojure/lang/IMeta.class +0 -0
  980. data/lib/clojure/lang/IObj.class +0 -0
  981. data/lib/clojure/lang/IPersistentCollection.class +0 -0
  982. data/lib/clojure/lang/IPersistentList.class +0 -0
  983. data/lib/clojure/lang/IPersistentMap.class +0 -0
  984. data/lib/clojure/lang/IPersistentSet.class +0 -0
  985. data/lib/clojure/lang/IPersistentStack.class +0 -0
  986. data/lib/clojure/lang/IPersistentVector.class +0 -0
  987. data/lib/clojure/lang/IProxy.class +0 -0
  988. data/lib/clojure/lang/IReduce.class +0 -0
  989. data/lib/clojure/lang/IRef.class +0 -0
  990. data/lib/clojure/lang/IReference.class +0 -0
  991. data/lib/clojure/lang/ISeq.class +0 -0
  992. data/lib/clojure/lang/IndexedSeq.class +0 -0
  993. data/lib/clojure/lang/IteratorSeq$State.class +0 -0
  994. data/lib/clojure/lang/IteratorSeq.class +0 -0
  995. data/lib/clojure/lang/IteratorStream.class +0 -0
  996. data/lib/clojure/lang/Keyword.class +0 -0
  997. data/lib/clojure/lang/LazilyPersistentVector.class +0 -0
  998. data/lib/clojure/lang/LazySeq.class +0 -0
  999. data/lib/clojure/lang/LineNumberingPushbackReader.class +0 -0
  1000. data/lib/clojure/lang/LispReader$ArgReader.class +0 -0
  1001. data/lib/clojure/lang/LispReader$CharacterReader.class +0 -0
  1002. data/lib/clojure/lang/LispReader$CommentReader.class +0 -0
  1003. data/lib/clojure/lang/LispReader$CtorReader.class +0 -0
  1004. data/lib/clojure/lang/LispReader$DiscardReader.class +0 -0
  1005. data/lib/clojure/lang/LispReader$DispatchReader.class +0 -0
  1006. data/lib/clojure/lang/LispReader$EvalReader.class +0 -0
  1007. data/lib/clojure/lang/LispReader$FnReader.class +0 -0
  1008. data/lib/clojure/lang/LispReader$ListReader.class +0 -0
  1009. data/lib/clojure/lang/LispReader$MapReader.class +0 -0
  1010. data/lib/clojure/lang/LispReader$MetaReader.class +0 -0
  1011. data/lib/clojure/lang/LispReader$ReaderException.class +0 -0
  1012. data/lib/clojure/lang/LispReader$RegexReader.class +0 -0
  1013. data/lib/clojure/lang/LispReader$SetReader.class +0 -0
  1014. data/lib/clojure/lang/LispReader$StringReader.class +0 -0
  1015. data/lib/clojure/lang/LispReader$SyntaxQuoteReader.class +0 -0
  1016. data/lib/clojure/lang/LispReader$UnmatchedDelimiterReader.class +0 -0
  1017. data/lib/clojure/lang/LispReader$UnquoteReader.class +0 -0
  1018. data/lib/clojure/lang/LispReader$UnreadableReader.class +0 -0
  1019. data/lib/clojure/lang/LispReader$VarReader.class +0 -0
  1020. data/lib/clojure/lang/LispReader$VectorReader.class +0 -0
  1021. data/lib/clojure/lang/LispReader$WrappingReader.class +0 -0
  1022. data/lib/clojure/lang/LispReader.class +0 -0
  1023. data/lib/clojure/lang/LockingTransaction$AbortException.class +0 -0
  1024. data/lib/clojure/lang/LockingTransaction$CFn.class +0 -0
  1025. data/lib/clojure/lang/LockingTransaction$Info.class +0 -0
  1026. data/lib/clojure/lang/LockingTransaction$Notify.class +0 -0
  1027. data/lib/clojure/lang/LockingTransaction$RetryEx.class +0 -0
  1028. data/lib/clojure/lang/LockingTransaction.class +0 -0
  1029. data/lib/clojure/lang/MapEntry.class +0 -0
  1030. data/lib/clojure/lang/MultiFn.class +0 -0
  1031. data/lib/clojure/lang/Named.class +0 -0
  1032. data/lib/clojure/lang/Namespace.class +0 -0
  1033. data/lib/clojure/lang/Numbers$BigDecimalOps.class +0 -0
  1034. data/lib/clojure/lang/Numbers$BigIntegerBitOps.class +0 -0
  1035. data/lib/clojure/lang/Numbers$BigIntegerOps.class +0 -0
  1036. data/lib/clojure/lang/Numbers$BitOps.class +0 -0
  1037. data/lib/clojure/lang/Numbers$DoubleOps.class +0 -0
  1038. data/lib/clojure/lang/Numbers$FloatOps.class +0 -0
  1039. data/lib/clojure/lang/Numbers$IntegerBitOps.class +0 -0
  1040. data/lib/clojure/lang/Numbers$IntegerOps.class +0 -0
  1041. data/lib/clojure/lang/Numbers$LongBitOps.class +0 -0
  1042. data/lib/clojure/lang/Numbers$LongOps.class +0 -0
  1043. data/lib/clojure/lang/Numbers$Ops.class +0 -0
  1044. data/lib/clojure/lang/Numbers$RatioOps.class +0 -0
  1045. data/lib/clojure/lang/Numbers.class +0 -0
  1046. data/lib/clojure/lang/Obj.class +0 -0
  1047. data/lib/clojure/lang/PersistentArrayMap$Iter.class +0 -0
  1048. data/lib/clojure/lang/PersistentArrayMap$Seq.class +0 -0
  1049. data/lib/clojure/lang/PersistentArrayMap.class +0 -0
  1050. data/lib/clojure/lang/PersistentHashMap$BitmapIndexedNode$Seq.class +0 -0
  1051. data/lib/clojure/lang/PersistentHashMap$BitmapIndexedNode.class +0 -0
  1052. data/lib/clojure/lang/PersistentHashMap$EmptyNode.class +0 -0
  1053. data/lib/clojure/lang/PersistentHashMap$FullNode$Seq.class +0 -0
  1054. data/lib/clojure/lang/PersistentHashMap$FullNode.class +0 -0
  1055. data/lib/clojure/lang/PersistentHashMap$HashCollisionNode.class +0 -0
  1056. data/lib/clojure/lang/PersistentHashMap$INode.class +0 -0
  1057. data/lib/clojure/lang/PersistentHashMap$LeafNode.class +0 -0
  1058. data/lib/clojure/lang/PersistentHashMap.class +0 -0
  1059. data/lib/clojure/lang/PersistentHashSet.class +0 -0
  1060. data/lib/clojure/lang/PersistentList$1.class +0 -0
  1061. data/lib/clojure/lang/PersistentList$EmptyList$1.class +0 -0
  1062. data/lib/clojure/lang/PersistentList$EmptyList.class +0 -0
  1063. data/lib/clojure/lang/PersistentList.class +0 -0
  1064. data/lib/clojure/lang/PersistentQueue$Seq.class +0 -0
  1065. data/lib/clojure/lang/PersistentQueue.class +0 -0
  1066. data/lib/clojure/lang/PersistentStructMap$1.class +0 -0
  1067. data/lib/clojure/lang/PersistentStructMap$Def.class +0 -0
  1068. data/lib/clojure/lang/PersistentStructMap$Seq.class +0 -0
  1069. data/lib/clojure/lang/PersistentStructMap.class +0 -0
  1070. data/lib/clojure/lang/PersistentTreeMap$Black.class +0 -0
  1071. data/lib/clojure/lang/PersistentTreeMap$BlackBranch.class +0 -0
  1072. data/lib/clojure/lang/PersistentTreeMap$BlackBranchVal.class +0 -0
  1073. data/lib/clojure/lang/PersistentTreeMap$BlackVal.class +0 -0
  1074. data/lib/clojure/lang/PersistentTreeMap$KeyIterator.class +0 -0
  1075. data/lib/clojure/lang/PersistentTreeMap$Node.class +0 -0
  1076. data/lib/clojure/lang/PersistentTreeMap$NodeIterator.class +0 -0
  1077. data/lib/clojure/lang/PersistentTreeMap$Red.class +0 -0
  1078. data/lib/clojure/lang/PersistentTreeMap$RedBranch.class +0 -0
  1079. data/lib/clojure/lang/PersistentTreeMap$RedBranchVal.class +0 -0
  1080. data/lib/clojure/lang/PersistentTreeMap$RedVal.class +0 -0
  1081. data/lib/clojure/lang/PersistentTreeMap$Seq.class +0 -0
  1082. data/lib/clojure/lang/PersistentTreeMap$ValIterator.class +0 -0
  1083. data/lib/clojure/lang/PersistentTreeMap.class +0 -0
  1084. data/lib/clojure/lang/PersistentTreeSet.class +0 -0
  1085. data/lib/clojure/lang/PersistentVector.class +0 -0
  1086. data/lib/clojure/lang/ProxyHandler.class +0 -0
  1087. data/lib/clojure/lang/RT$1.class +0 -0
  1088. data/lib/clojure/lang/RT$2.class +0 -0
  1089. data/lib/clojure/lang/RT$3.class +0 -0
  1090. data/lib/clojure/lang/RT$4.class +0 -0
  1091. data/lib/clojure/lang/RT$5.class +0 -0
  1092. data/lib/clojure/lang/RT$6.class +0 -0
  1093. data/lib/clojure/lang/RT.class +0 -0
  1094. data/lib/clojure/lang/Range$Src.class +0 -0
  1095. data/lib/clojure/lang/Range.class +0 -0
  1096. data/lib/clojure/lang/Ratio.class +0 -0
  1097. data/lib/clojure/lang/Ref$TVal.class +0 -0
  1098. data/lib/clojure/lang/Ref.class +0 -0
  1099. data/lib/clojure/lang/Reflector.class +0 -0
  1100. data/lib/clojure/lang/Repl.class +0 -0
  1101. data/lib/clojure/lang/RestFn.class +0 -0
  1102. data/lib/clojure/lang/Reversible.class +0 -0
  1103. data/lib/clojure/lang/Script.class +0 -0
  1104. data/lib/clojure/lang/SeqEnumeration.class +0 -0
  1105. data/lib/clojure/lang/SeqIterator.class +0 -0
  1106. data/lib/clojure/lang/Seqable.class +0 -0
  1107. data/lib/clojure/lang/Sequential.class +0 -0
  1108. data/lib/clojure/lang/Settable.class +0 -0
  1109. data/lib/clojure/lang/Sorted.class +0 -0
  1110. data/lib/clojure/lang/Stream$1.class +0 -0
  1111. data/lib/clojure/lang/Stream$2.class +0 -0
  1112. data/lib/clojure/lang/Stream.class +0 -0
  1113. data/lib/clojure/lang/Streamable.class +0 -0
  1114. data/lib/clojure/lang/StringSeq.class +0 -0
  1115. data/lib/clojure/lang/Symbol.class +0 -0
  1116. data/lib/clojure/lang/TransactionalHashMap$1.class +0 -0
  1117. data/lib/clojure/lang/TransactionalHashMap.class +0 -0
  1118. data/lib/clojure/lang/Util.class +0 -0
  1119. data/lib/clojure/lang/Var$1.class +0 -0
  1120. data/lib/clojure/lang/Var$2.class +0 -0
  1121. data/lib/clojure/lang/Var$Frame.class +0 -0
  1122. data/lib/clojure/lang/Var.class +0 -0
  1123. data/lib/clojure/lang/XMLHandler.class +0 -0
  1124. data/lib/clojure/main$eval_opt__5839.class +0 -0
  1125. data/lib/clojure/main$help_opt__5871.class +0 -0
  1126. data/lib/clojure/main$init_dispatch__5843.class +0 -0
  1127. data/lib/clojure/main$init_opt__5836.class +0 -0
  1128. data/lib/clojure/main$initialize__5846.class +0 -0
  1129. data/lib/clojure/main$legacy_repl__5878.class +0 -0
  1130. data/lib/clojure/main$legacy_script__5883.class +0 -0
  1131. data/lib/clojure/main$load_script__5833.class +0 -0
  1132. data/lib/clojure/main$main__5888.class +0 -0
  1133. data/lib/clojure/main$main_dispatch__5874.class +0 -0
  1134. data/lib/clojure/main$null_opt__5868.class +0 -0
  1135. data/lib/clojure/main$repl__5813$fn__5816.class +0 -0
  1136. data/lib/clojure/main$repl__5813$fn__5819.class +0 -0
  1137. data/lib/clojure/main$repl__5813$fn__5822.class +0 -0
  1138. data/lib/clojure/main$repl__5813$fn__5829.class +0 -0
  1139. data/lib/clojure/main$repl__5813$read_eval_print__5825.class +0 -0
  1140. data/lib/clojure/main$repl__5813.class +0 -0
  1141. data/lib/clojure/main$repl_caught__5810.class +0 -0
  1142. data/lib/clojure/main$repl_exception__5807.class +0 -0
  1143. data/lib/clojure/main$repl_opt__5853$fn__5856.class +0 -0
  1144. data/lib/clojure/main$repl_opt__5853$fn__5859.class +0 -0
  1145. data/lib/clojure/main$repl_opt__5853.class +0 -0
  1146. data/lib/clojure/main$repl_prompt__5789.class +0 -0
  1147. data/lib/clojure/main$repl_read__5799.class +0 -0
  1148. data/lib/clojure/main$root_cause__5803.class +0 -0
  1149. data/lib/clojure/main$script_opt__5864.class +0 -0
  1150. data/lib/clojure/main$skip_if_eol__5792.class +0 -0
  1151. data/lib/clojure/main$skip_whitespace__5795.class +0 -0
  1152. data/lib/clojure/main$with_bindings__5786.class +0 -0
  1153. data/lib/clojure/main.class +0 -0
  1154. data/lib/clojure/main.clj +337 -0
  1155. data/lib/clojure/main__init.class +0 -0
  1156. data/lib/clojure/parallel.clj +248 -0
  1157. data/lib/clojure/proxy/clojure/lang/APersistentMap.class +0 -0
  1158. data/lib/clojure/proxy/java/lang/Object$ContentHandler.class +0 -0
  1159. data/lib/clojure/proxy/java/lang/Object$Future$IDeref.class +0 -0
  1160. data/lib/clojure/proxy/java/lang/Object$TableModel.class +0 -0
  1161. data/lib/clojure/proxy/java/lang/Object$TreeModel.class +0 -0
  1162. data/lib/clojure/proxy/javax/swing/table/AbstractTableModel.class +0 -0
  1163. data/lib/clojure/set$bubble_max_key__5896$fn__5898.class +0 -0
  1164. data/lib/clojure/set$bubble_max_key__5896.class +0 -0
  1165. data/lib/clojure/set$difference__5920$fn__5923.class +0 -0
  1166. data/lib/clojure/set$difference__5920.class +0 -0
  1167. data/lib/clojure/set$index__5956$fn__5958.class +0 -0
  1168. data/lib/clojure/set$index__5956.class +0 -0
  1169. data/lib/clojure/set$intersection__5909$fn__5912.class +0 -0
  1170. data/lib/clojure/set$intersection__5909$fn__5916.class +0 -0
  1171. data/lib/clojure/set$intersection__5909.class +0 -0
  1172. data/lib/clojure/set$join__5974$fn__5977$fn__5979.class +0 -0
  1173. data/lib/clojure/set$join__5974$fn__5977.class +0 -0
  1174. data/lib/clojure/set$join__5974$fn__5985$fn__5987.class +0 -0
  1175. data/lib/clojure/set$join__5974$fn__5985.class +0 -0
  1176. data/lib/clojure/set$join__5974.class +0 -0
  1177. data/lib/clojure/set$map_invert__5962$fn__5965.class +0 -0
  1178. data/lib/clojure/set$map_invert__5962.class +0 -0
  1179. data/lib/clojure/set$project__5935$fn__5937.class +0 -0
  1180. data/lib/clojure/set$project__5935.class +0 -0
  1181. data/lib/clojure/set$rename__5950$fn__5952.class +0 -0
  1182. data/lib/clojure/set$rename__5950.class +0 -0
  1183. data/lib/clojure/set$rename_keys__5941$fn__5944.class +0 -0
  1184. data/lib/clojure/set$rename_keys__5941.class +0 -0
  1185. data/lib/clojure/set$select__5928$fn__5930.class +0 -0
  1186. data/lib/clojure/set$select__5928.class +0 -0
  1187. data/lib/clojure/set$union__5902.class +0 -0
  1188. data/lib/clojure/set.clj +148 -0
  1189. data/lib/clojure/set__init.class +0 -0
  1190. data/lib/clojure/version.properties +5 -0
  1191. data/lib/clojure/xml$emit__6057.class +0 -0
  1192. data/lib/clojure/xml$emit_element__6052.class +0 -0
  1193. data/lib/clojure/xml$fn__5994$fn__6007.class +0 -0
  1194. data/lib/clojure/xml$fn__5994$fn__6010.class +0 -0
  1195. data/lib/clojure/xml$fn__5994$fn__6013.class +0 -0
  1196. data/lib/clojure/xml$fn__5994$fn__6016.class +0 -0
  1197. data/lib/clojure/xml$fn__5994$fn__6019.class +0 -0
  1198. data/lib/clojure/xml$fn__5994$fn__6022.class +0 -0
  1199. data/lib/clojure/xml$fn__5994$fn__6025.class +0 -0
  1200. data/lib/clojure/xml$fn__5994$fn__6028$attrs__6030.class +0 -0
  1201. data/lib/clojure/xml$fn__5994$fn__6028.class +0 -0
  1202. data/lib/clojure/xml$fn__5994$fn__6034.class +0 -0
  1203. data/lib/clojure/xml$fn__5994$fn__6037.class +0 -0
  1204. data/lib/clojure/xml$fn__5994$fn__6040.class +0 -0
  1205. data/lib/clojure/xml$fn__5994$push_chars__6000$fn__6002.class +0 -0
  1206. data/lib/clojure/xml$fn__5994$push_chars__6000.class +0 -0
  1207. data/lib/clojure/xml$fn__5994$push_content__5996.class +0 -0
  1208. data/lib/clojure/xml$fn__5994.class +0 -0
  1209. data/lib/clojure/xml$parse__6048.class +0 -0
  1210. data/lib/clojure/xml$startparse_sax__6045.class +0 -0
  1211. data/lib/clojure/xml.clj +115 -0
  1212. data/lib/clojure/xml__init.class +0 -0
  1213. data/lib/clojure/zip$append_child__6155.class +0 -0
  1214. data/lib/clojure/zip$branch_QMARK___6085.class +0 -0
  1215. data/lib/clojure/zip$children__6088.class +0 -0
  1216. data/lib/clojure/zip$down__6103.class +0 -0
  1217. data/lib/clojure/zip$edit__6149.class +0 -0
  1218. data/lib/clojure/zip$end_QMARK___6171.class +0 -0
  1219. data/lib/clojure/zip$insert_child__6152.class +0 -0
  1220. data/lib/clojure/zip$insert_left__6137.class +0 -0
  1221. data/lib/clojure/zip$insert_right__6141.class +0 -0
  1222. data/lib/clojure/zip$left__6127.class +0 -0
  1223. data/lib/clojure/zip$leftmost__6132.class +0 -0
  1224. data/lib/clojure/zip$lefts__6097.class +0 -0
  1225. data/lib/clojure/zip$make_node__6091.class +0 -0
  1226. data/lib/clojure/zip$next__6158.class +0 -0
  1227. data/lib/clojure/zip$node__6082.class +0 -0
  1228. data/lib/clojure/zip$path__6094.class +0 -0
  1229. data/lib/clojure/zip$prev__6165.class +0 -0
  1230. data/lib/clojure/zip$remove__6174.class +0 -0
  1231. data/lib/clojure/zip$replace__6145.class +0 -0
  1232. data/lib/clojure/zip$right__6116.class +0 -0
  1233. data/lib/clojure/zip$rightmost__6122.class +0 -0
  1234. data/lib/clojure/zip$rights__6100.class +0 -0
  1235. data/lib/clojure/zip$root__6113.class +0 -0
  1236. data/lib/clojure/zip$seq_zip__6063$fn__6065.class +0 -0
  1237. data/lib/clojure/zip$seq_zip__6063.class +0 -0
  1238. data/lib/clojure/zip$up__6108.class +0 -0
  1239. data/lib/clojure/zip$vector_zip__6069$fn__6071.class +0 -0
  1240. data/lib/clojure/zip$vector_zip__6069.class +0 -0
  1241. data/lib/clojure/zip$xml_zip__6075$fn__6077.class +0 -0
  1242. data/lib/clojure/zip$xml_zip__6075.class +0 -0
  1243. data/lib/clojure/zip$zipper__6060.class +0 -0
  1244. data/lib/clojure/zip.clj +278 -0
  1245. data/lib/clojure/zip__init.class +0 -0
  1246. data/src/clj/clojure/core.clj +4121 -0
  1247. data/src/clj/clojure/core_print.clj +317 -0
  1248. data/src/clj/clojure/core_proxy.clj +394 -0
  1249. data/src/clj/clojure/genclass.clj +683 -0
  1250. data/src/clj/clojure/inspector.clj +180 -0
  1251. data/src/clj/clojure/main.clj +337 -0
  1252. data/src/clj/clojure/parallel.clj +248 -0
  1253. data/src/clj/clojure/set.clj +148 -0
  1254. data/src/clj/clojure/version.properties +5 -0
  1255. data/src/clj/clojure/xml.clj +115 -0
  1256. data/src/clj/clojure/zip.clj +278 -0
  1257. data/src/jvm/clojure/asm/AnnotationVisitor.java +97 -0
  1258. data/src/jvm/clojure/asm/AnnotationWriter.java +357 -0
  1259. data/src/jvm/clojure/asm/Attribute.java +253 -0
  1260. data/src/jvm/clojure/asm/ByteVector.java +318 -0
  1261. data/src/jvm/clojure/asm/ClassAdapter.java +115 -0
  1262. data/src/jvm/clojure/asm/ClassReader.java +2224 -0
  1263. data/src/jvm/clojure/asm/ClassVisitor.java +196 -0
  1264. data/src/jvm/clojure/asm/ClassWriter.java +1415 -0
  1265. data/src/jvm/clojure/asm/Edge.java +75 -0
  1266. data/src/jvm/clojure/asm/FieldVisitor.java +64 -0
  1267. data/src/jvm/clojure/asm/FieldWriter.java +290 -0
  1268. data/src/jvm/clojure/asm/Frame.java +1506 -0
  1269. data/src/jvm/clojure/asm/Handler.java +70 -0
  1270. data/src/jvm/clojure/asm/Item.java +258 -0
  1271. data/src/jvm/clojure/asm/Label.java +437 -0
  1272. data/src/jvm/clojure/asm/MethodAdapter.java +186 -0
  1273. data/src/jvm/clojure/asm/MethodVisitor.java +396 -0
  1274. data/src/jvm/clojure/asm/MethodWriter.java +3029 -0
  1275. data/src/jvm/clojure/asm/Opcodes.java +341 -0
  1276. data/src/jvm/clojure/asm/Type.java +872 -0
  1277. data/src/jvm/clojure/asm/commons/AdviceAdapter.java +681 -0
  1278. data/src/jvm/clojure/asm/commons/AnalyzerAdapter.java +938 -0
  1279. data/src/jvm/clojure/asm/commons/CodeSizeEvaluator.java +234 -0
  1280. data/src/jvm/clojure/asm/commons/EmptyVisitor.java +221 -0
  1281. data/src/jvm/clojure/asm/commons/GeneratorAdapter.java +1533 -0
  1282. data/src/jvm/clojure/asm/commons/LocalVariablesSorter.java +330 -0
  1283. data/src/jvm/clojure/asm/commons/Method.java +267 -0
  1284. data/src/jvm/clojure/asm/commons/SerialVersionUIDAdder.java +508 -0
  1285. data/src/jvm/clojure/asm/commons/StaticInitMerger.java +102 -0
  1286. data/src/jvm/clojure/asm/commons/TableSwitchGenerator.java +55 -0
  1287. data/src/jvm/clojure/asm/commons/package.html +48 -0
  1288. data/src/jvm/clojure/asm/package.html +87 -0
  1289. data/src/jvm/clojure/lang/AFn.java +452 -0
  1290. data/src/jvm/clojure/lang/AFunction.java +47 -0
  1291. data/src/jvm/clojure/lang/AMapEntry.java +149 -0
  1292. data/src/jvm/clojure/lang/APersistentMap.java +382 -0
  1293. data/src/jvm/clojure/lang/APersistentSet.java +159 -0
  1294. data/src/jvm/clojure/lang/APersistentVector.java +579 -0
  1295. data/src/jvm/clojure/lang/ARef.java +107 -0
  1296. data/src/jvm/clojure/lang/AReference.java +40 -0
  1297. data/src/jvm/clojure/lang/ASeq.java +282 -0
  1298. data/src/jvm/clojure/lang/Agent.java +194 -0
  1299. data/src/jvm/clojure/lang/ArraySeq.java +316 -0
  1300. data/src/jvm/clojure/lang/ArrayStream.java +184 -0
  1301. data/src/jvm/clojure/lang/Associative.java +22 -0
  1302. data/src/jvm/clojure/lang/Atom.java +104 -0
  1303. data/src/jvm/clojure/lang/Binding.java +26 -0
  1304. data/src/jvm/clojure/lang/Box.java +22 -0
  1305. data/src/jvm/clojure/lang/Compile.java +73 -0
  1306. data/src/jvm/clojure/lang/Compiler.java +5017 -0
  1307. data/src/jvm/clojure/lang/Cons.java +53 -0
  1308. data/src/jvm/clojure/lang/Counted.java +18 -0
  1309. data/src/jvm/clojure/lang/Delay.java +38 -0
  1310. data/src/jvm/clojure/lang/DynamicClassLoader.java +71 -0
  1311. data/src/jvm/clojure/lang/EnumerationSeq.java +71 -0
  1312. data/src/jvm/clojure/lang/Fn.java +16 -0
  1313. data/src/jvm/clojure/lang/IDeref.java +17 -0
  1314. data/src/jvm/clojure/lang/IFn.java +90 -0
  1315. data/src/jvm/clojure/lang/IMapEntry.java +19 -0
  1316. data/src/jvm/clojure/lang/IMeta.java +17 -0
  1317. data/src/jvm/clojure/lang/IObj.java +18 -0
  1318. data/src/jvm/clojure/lang/IPersistentCollection.java +23 -0
  1319. data/src/jvm/clojure/lang/IPersistentList.java +16 -0
  1320. data/src/jvm/clojure/lang/IPersistentMap.java +23 -0
  1321. data/src/jvm/clojure/lang/IPersistentSet.java +19 -0
  1322. data/src/jvm/clojure/lang/IPersistentStack.java +19 -0
  1323. data/src/jvm/clojure/lang/IPersistentVector.java +22 -0
  1324. data/src/jvm/clojure/lang/IProxy.java +21 -0
  1325. data/src/jvm/clojure/lang/IReduce.java +19 -0
  1326. data/src/jvm/clojure/lang/IRef.java +27 -0
  1327. data/src/jvm/clojure/lang/IReference.java +18 -0
  1328. data/src/jvm/clojure/lang/ISeq.java +29 -0
  1329. data/src/jvm/clojure/lang/IndexedSeq.java +16 -0
  1330. data/src/jvm/clojure/lang/IteratorSeq.java +69 -0
  1331. data/src/jvm/clojure/lang/IteratorStream.java +29 -0
  1332. data/src/jvm/clojure/lang/Keyword.java +199 -0
  1333. data/src/jvm/clojure/lang/LazilyPersistentVector.java +79 -0
  1334. data/src/jvm/clojure/lang/LazySeq.java +233 -0
  1335. data/src/jvm/clojure/lang/LineNumberingPushbackReader.java +75 -0
  1336. data/src/jvm/clojure/lang/LispReader.java +1063 -0
  1337. data/src/jvm/clojure/lang/LockingTransaction.java +583 -0
  1338. data/src/jvm/clojure/lang/MapEntry.java +40 -0
  1339. data/src/jvm/clojure/lang/MultiFn.java +308 -0
  1340. data/src/jvm/clojure/lang/Named.java +19 -0
  1341. data/src/jvm/clojure/lang/Namespace.java +178 -0
  1342. data/src/jvm/clojure/lang/Numbers.java +4371 -0
  1343. data/src/jvm/clojure/lang/Obj.java +33 -0
  1344. data/src/jvm/clojure/lang/PersistentArrayMap.java +263 -0
  1345. data/src/jvm/clojure/lang/PersistentHashMap.java +746 -0
  1346. data/src/jvm/clojure/lang/PersistentHashSet.java +72 -0
  1347. data/src/jvm/clojure/lang/PersistentList.java +298 -0
  1348. data/src/jvm/clojure/lang/PersistentQueue.java +304 -0
  1349. data/src/jvm/clojure/lang/PersistentStructMap.java +225 -0
  1350. data/src/jvm/clojure/lang/PersistentTreeMap.java +998 -0
  1351. data/src/jvm/clojure/lang/PersistentTreeSet.java +94 -0
  1352. data/src/jvm/clojure/lang/PersistentVector.java +320 -0
  1353. data/src/jvm/clojure/lang/ProxyHandler.java +72 -0
  1354. data/src/jvm/clojure/lang/RT.java +1676 -0
  1355. data/src/jvm/clojure/lang/Range.java +85 -0
  1356. data/src/jvm/clojure/lang/Ratio.java +74 -0
  1357. data/src/jvm/clojure/lang/Ref.java +335 -0
  1358. data/src/jvm/clojure/lang/Reflector.java +448 -0
  1359. data/src/jvm/clojure/lang/Repl.java +22 -0
  1360. data/src/jvm/clojure/lang/RestFn.java +1335 -0
  1361. data/src/jvm/clojure/lang/Reversible.java +17 -0
  1362. data/src/jvm/clojure/lang/Script.java +22 -0
  1363. data/src/jvm/clojure/lang/SeqEnumeration.java +33 -0
  1364. data/src/jvm/clojure/lang/SeqIterator.java +41 -0
  1365. data/src/jvm/clojure/lang/Seqable.java +17 -0
  1366. data/src/jvm/clojure/lang/Sequential.java +13 -0
  1367. data/src/jvm/clojure/lang/Settable.java +18 -0
  1368. data/src/jvm/clojure/lang/Sorted.java +25 -0
  1369. data/src/jvm/clojure/lang/Stream.java +88 -0
  1370. data/src/jvm/clojure/lang/Streamable.java +17 -0
  1371. data/src/jvm/clojure/lang/StringSeq.java +50 -0
  1372. data/src/jvm/clojure/lang/Symbol.java +121 -0
  1373. data/src/jvm/clojure/lang/TransactionalHashMap.java +197 -0
  1374. data/src/jvm/clojure/lang/Util.java +74 -0
  1375. data/src/jvm/clojure/lang/Var.java +472 -0
  1376. data/src/jvm/clojure/lang/XMLHandler.java +89 -0
  1377. data/src/jvm/clojure/main.java +41 -0
  1378. metadata +1433 -0
@@ -0,0 +1,4121 @@
1
+ ; Copyright (c) Rich Hickey. All rights reserved.
2
+ ; The use and distribution terms for this software are covered by the
3
+ ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
4
+ ; which can be found in the file epl-v10.html at the root of this distribution.
5
+ ; By using this software in any fashion, you are agreeing to be bound by
6
+ ; the terms of this license.
7
+ ; You must not remove this notice, or any other, from this software.
8
+
9
+ (ns clojure.core)
10
+
11
+ (def unquote)
12
+ (def unquote-splicing)
13
+
14
+ (def
15
+ #^{:arglists '([& items])
16
+ :doc "Creates a new list containing the items."}
17
+ list (. clojure.lang.PersistentList creator))
18
+
19
+ (def
20
+ #^{:arglists '([x seq])
21
+ :doc "Returns a new seq where x is the first element and seq is
22
+ the rest."}
23
+
24
+ cons (fn* cons [x seq] (. clojure.lang.RT (cons x seq))))
25
+
26
+ ;during bootstrap we don't have destructuring let, loop or fn, will redefine later
27
+ (def
28
+ #^{:macro true}
29
+ let (fn* let [& decl] (cons 'let* decl)))
30
+
31
+ (def
32
+ #^{:macro true}
33
+ loop (fn* loop [& decl] (cons 'loop* decl)))
34
+
35
+ (def
36
+ #^{:macro true}
37
+ fn (fn* fn [& decl] (cons 'fn* decl)))
38
+
39
+ (def
40
+ #^{:arglists '([coll])
41
+ :doc "Returns the first item in the collection. Calls seq on its
42
+ argument. If coll is nil, returns nil."}
43
+ first (fn first [coll] (. clojure.lang.RT (first coll))))
44
+
45
+ (def
46
+ #^{:arglists '([coll])
47
+ :tag clojure.lang.ISeq
48
+ :doc "Returns a seq of the items after the first. Calls seq on its
49
+ argument. If there are no more items, returns nil."}
50
+ next (fn next [x] (. clojure.lang.RT (next x))))
51
+
52
+ (def
53
+ #^{:arglists '([coll])
54
+ :tag clojure.lang.ISeq
55
+ :doc "Returns a possibly empty seq of the items after the first. Calls seq on its
56
+ argument."}
57
+ rest (fn rest [x] (. clojure.lang.RT (more x))))
58
+
59
+ (def
60
+ #^{:arglists '([coll x] [coll x & xs])
61
+ :doc "conj[oin]. Returns a new collection with the xs
62
+ 'added'. (conj nil item) returns (item). The 'addition' may
63
+ happen at different 'places' depending on the concrete type."}
64
+ conj (fn conj
65
+ ([coll x] (. clojure.lang.RT (conj coll x)))
66
+ ([coll x & xs]
67
+ (if xs
68
+ (recur (conj coll x) (first xs) (next xs))
69
+ (conj coll x)))))
70
+
71
+ (def
72
+ #^{:doc "Same as (first (next x))"
73
+ :arglists '([x])}
74
+ second (fn second [x] (first (next x))))
75
+
76
+ (def
77
+ #^{:doc "Same as (first (first x))"
78
+ :arglists '([x])}
79
+ ffirst (fn ffirst [x] (first (first x))))
80
+
81
+ (def
82
+ #^{:doc "Same as (next (first x))"
83
+ :arglists '([x])}
84
+ nfirst (fn nfirst [x] (next (first x))))
85
+
86
+ (def
87
+ #^{:doc "Same as (first (next x))"
88
+ :arglists '([x])}
89
+ fnext (fn fnext [x] (first (next x))))
90
+
91
+ (def
92
+ #^{:doc "Same as (next (next x))"
93
+ :arglists '([x])}
94
+ nnext (fn nnext [x] (next (next x))))
95
+
96
+ (def
97
+ #^{:arglists '([coll])
98
+ :doc "Returns a seq on the collection. If the collection is
99
+ empty, returns nil. (seq nil) returns nil. seq also works on
100
+ Strings, native Java arrays (of reference types) and any objects
101
+ that implement Iterable."
102
+ :tag clojure.lang.ISeq}
103
+ seq (fn seq [coll] (. clojure.lang.RT (seq coll))))
104
+
105
+ (def
106
+ #^{:arglists '([#^Class c x])
107
+ :doc "Evaluates x and tests if it is an instance of the class
108
+ c. Returns true or false"}
109
+ instance? (fn instance? [#^Class c x] (. c (isInstance x))))
110
+
111
+ (def
112
+ #^{:arglists '([x])
113
+ :doc "Return true if x implements ISeq"}
114
+ seq? (fn seq? [x] (instance? clojure.lang.ISeq x)))
115
+
116
+ (def
117
+ #^{:arglists '([x])
118
+ :doc "Return true if x is a String"}
119
+ string? (fn string? [x] (instance? String x)))
120
+
121
+ (def
122
+ #^{:arglists '([x])
123
+ :doc "Return true if x implements IPersistentMap"}
124
+ map? (fn map? [x] (instance? clojure.lang.IPersistentMap x)))
125
+
126
+ (def
127
+ #^{:arglists '([x])
128
+ :doc "Return true if x implements IPersistentVector "}
129
+ vector? (fn vector? [x] (instance? clojure.lang.IPersistentVector x)))
130
+
131
+ (def
132
+ #^{:private true}
133
+ sigs
134
+ (fn [fdecl]
135
+ (if (seq? (first fdecl))
136
+ (loop [ret [] fdecl fdecl]
137
+ (if fdecl
138
+ (recur (conj ret (first (first fdecl))) (next fdecl))
139
+ (seq ret)))
140
+ (list (first fdecl)))))
141
+
142
+ (def
143
+ #^{:arglists '([map key val] [map key val & kvs])
144
+ :doc "assoc[iate]. When applied to a map, returns a new map of the
145
+ same (hashed/sorted) type, that contains the mapping of key(s) to
146
+ val(s). When applied to a vector, returns a new vector that
147
+ contains val at index. Note - index must be <= (count vector)."}
148
+ assoc
149
+ (fn assoc
150
+ ([map key val] (. clojure.lang.RT (assoc map key val)))
151
+ ([map key val & kvs]
152
+ (let [ret (assoc map key val)]
153
+ (if kvs
154
+ (recur ret (first kvs) (second kvs) (nnext kvs))
155
+ ret)))))
156
+
157
+ ;;;;;;;;;;;;;;;;; metadata ;;;;;;;;;;;;;;;;;;;;;;;;;;;
158
+ (def
159
+ #^{:arglists '([obj])
160
+ :doc "Returns the metadata of obj, returns nil if there is no metadata."}
161
+ meta (fn meta [x]
162
+ (if (instance? clojure.lang.IMeta x)
163
+ (. #^clojure.lang.IMeta x (meta)))))
164
+
165
+ (def
166
+ #^{:arglists '([#^clojure.lang.IObj obj m])
167
+ :doc "Returns an object of the same type and value as obj, with
168
+ map m as its metadata."}
169
+ with-meta (fn with-meta [#^clojure.lang.IObj x m]
170
+ (. x (withMeta m))))
171
+
172
+ (def
173
+ #^{:arglists '([coll])
174
+ :doc "Return the last item in coll, in linear time"}
175
+ last (fn last [s]
176
+ (if (next s)
177
+ (recur (next s))
178
+ (first s))))
179
+
180
+ (def
181
+ #^{:arglists '([coll])
182
+ :doc "Return a seq of all but the last item in coll, in linear time"}
183
+ butlast (fn butlast [s]
184
+ (loop [ret [] s s]
185
+ (if (next s)
186
+ (recur (conj ret (first s)) (next s))
187
+ (seq ret)))))
188
+
189
+ (def
190
+
191
+ #^{:doc "Same as (def name (fn [params* ] exprs*)) or (def
192
+ name (fn ([params* ] exprs*)+)) with any doc-string or attrs added
193
+ to the var metadata"
194
+ :arglists '([name doc-string? attr-map? [params*] body]
195
+ [name doc-string? attr-map? ([params*] body)+ attr-map?])}
196
+ defn (fn defn [name & fdecl]
197
+ (let [m (if (string? (first fdecl))
198
+ {:doc (first fdecl)}
199
+ {})
200
+ fdecl (if (string? (first fdecl))
201
+ (next fdecl)
202
+ fdecl)
203
+ m (if (map? (first fdecl))
204
+ (conj m (first fdecl))
205
+ m)
206
+ fdecl (if (map? (first fdecl))
207
+ (next fdecl)
208
+ fdecl)
209
+ fdecl (if (vector? (first fdecl))
210
+ (list fdecl)
211
+ fdecl)
212
+ m (if (map? (last fdecl))
213
+ (conj m (last fdecl))
214
+ m)
215
+ fdecl (if (map? (last fdecl))
216
+ (butlast fdecl)
217
+ fdecl)
218
+ m (conj {:arglists (list 'quote (sigs fdecl))} m)]
219
+ (list 'def (with-meta name (conj (if (meta name) (meta name) {}) m))
220
+ (cons `fn fdecl)))))
221
+
222
+ (. (var defn) (setMacro))
223
+
224
+ (defn cast
225
+ "Throws a ClassCastException if x is not a c, else returns x."
226
+ [#^Class c x]
227
+ (. c (cast x)))
228
+
229
+ (defn to-array
230
+ "Returns an array of Objects containing the contents of coll, which
231
+ can be any Collection. Maps to java.util.Collection.toArray()."
232
+ {:tag "[Ljava.lang.Object;"}
233
+ [coll] (. clojure.lang.RT (toArray coll)))
234
+
235
+ (defn vector
236
+ "Creates a new vector containing the args."
237
+ ([] [])
238
+ ([& args]
239
+ (. clojure.lang.LazilyPersistentVector (create args))))
240
+
241
+ (defn vec
242
+ "Creates a new vector containing the contents of coll."
243
+ ([coll]
244
+ (. clojure.lang.LazilyPersistentVector (createOwning (to-array coll)))))
245
+
246
+ (defn hash-map
247
+ "keyval => key val
248
+ Returns a new hash map with supplied mappings."
249
+ ([] {})
250
+ ([& keyvals]
251
+ (. clojure.lang.PersistentHashMap (create keyvals))))
252
+
253
+ (defn hash-set
254
+ "Returns a new hash set with supplied keys."
255
+ ([] #{})
256
+ ([& keys]
257
+ (. clojure.lang.PersistentHashSet (create keys))))
258
+
259
+ (defn sorted-map
260
+ "keyval => key val
261
+ Returns a new sorted map with supplied mappings."
262
+ ([& keyvals]
263
+ (. clojure.lang.PersistentTreeMap (create keyvals))))
264
+
265
+ (defn sorted-set
266
+ "Returns a new sorted set with supplied keys."
267
+ ([& keys]
268
+ (. clojure.lang.PersistentTreeSet (create keys))))
269
+
270
+ (defn sorted-map-by
271
+ "keyval => key val
272
+ Returns a new sorted map with supplied mappings, using the supplied comparator."
273
+ ([comparator & keyvals]
274
+ (. clojure.lang.PersistentTreeMap (create comparator keyvals))))
275
+
276
+ ;;;;;;;;;;;;;;;;;;;;
277
+ (def
278
+
279
+ #^{:doc "Like defn, but the resulting function name is declared as a
280
+ macro and will be used as a macro by the compiler when it is
281
+ called."
282
+ :arglists '([name doc-string? attr-map? [params*] body]
283
+ [name doc-string? attr-map? ([params*] body)+ attr-map?])}
284
+ defmacro (fn [name & args]
285
+ (list 'do
286
+ (cons `defn (cons name args))
287
+ (list '. (list 'var name) '(setMacro))
288
+ (list 'var name))))
289
+
290
+ (. (var defmacro) (setMacro))
291
+
292
+ (defmacro when
293
+ "Evaluates test. If logical true, evaluates body in an implicit do."
294
+ [test & body]
295
+ (list 'if test (cons 'do body)))
296
+
297
+ (defmacro when-not
298
+ "Evaluates test. If logical false, evaluates body in an implicit do."
299
+ [test & body]
300
+ (list 'if test nil (cons 'do body)))
301
+
302
+ (defn nil?
303
+ "Returns true if x is nil, false otherwise."
304
+ {:tag Boolean}
305
+ [x] (identical? x nil))
306
+
307
+ (defn false?
308
+ "Returns true if x is the value false, false otherwise."
309
+ {:tag Boolean}
310
+ [x] (identical? x false))
311
+
312
+ (defn true?
313
+ "Returns true if x is the value true, false otherwise."
314
+ {:tag Boolean}
315
+ [x] (identical? x true))
316
+
317
+ (defn not
318
+ "Returns true if x is logical false, false otherwise."
319
+ {:tag Boolean}
320
+ [x] (if x false true))
321
+
322
+ (defn str
323
+ "With no args, returns the empty string. With one arg x, returns
324
+ x.toString(). (str nil) returns the empty string. With more than
325
+ one arg, returns the concatenation of the str values of the args."
326
+ {:tag String}
327
+ ([] "")
328
+ ([#^Object x]
329
+ (if (nil? x) "" (. x (toString))))
330
+ ([x & ys]
331
+ ((fn [#^StringBuilder sb more]
332
+ (if more
333
+ (recur (. sb (append (str (first more)))) (next more))
334
+ (str sb)))
335
+ (new StringBuilder #^String (str x)) ys)))
336
+
337
+
338
+ (defn symbol?
339
+ "Return true if x is a Symbol"
340
+ [x] (instance? clojure.lang.Symbol x))
341
+
342
+ (defn keyword?
343
+ "Return true if x is a Keyword"
344
+ [x] (instance? clojure.lang.Keyword x))
345
+
346
+ (defn symbol
347
+ "Returns a Symbol with the given namespace and name."
348
+ ([name] (if (symbol? name) name (. clojure.lang.Symbol (intern name))))
349
+ ([ns name] (. clojure.lang.Symbol (intern ns name))))
350
+
351
+ (defn keyword
352
+ "Returns a Keyword with the given namespace and name. Do not use :
353
+ in the keyword strings, it will be added automatically."
354
+ ([name] (if (keyword? name) name (. clojure.lang.Keyword (intern nil name))))
355
+ ([ns name] (. clojure.lang.Keyword (intern ns name))))
356
+
357
+ (defn gensym
358
+ "Returns a new symbol with a unique name. If a prefix string is
359
+ supplied, the name is prefix# where # is some unique number. If
360
+ prefix is not supplied, the prefix is 'G__'."
361
+ ([] (gensym "G__"))
362
+ ([prefix-string] (. clojure.lang.Symbol (intern (str prefix-string (str (. clojure.lang.RT (nextID))))))))
363
+
364
+ (defmacro cond
365
+ "Takes a set of test/expr pairs. It evaluates each test one at a
366
+ time. If a test returns logical true, cond evaluates and returns
367
+ the value of the corresponding expr and doesn't evaluate any of the
368
+ other tests or exprs. (cond) returns nil."
369
+ [& clauses]
370
+ (when clauses
371
+ (list 'if (first clauses)
372
+ (if (next clauses)
373
+ (second clauses)
374
+ (throw (IllegalArgumentException.
375
+ "cond requires an even number of forms")))
376
+ (cons 'clojure.core/cond (next (next clauses))))))
377
+
378
+ (defn spread
379
+ {:private true}
380
+ [arglist]
381
+ (cond
382
+ (nil? arglist) nil
383
+ (nil? (next arglist)) (seq (first arglist))
384
+ :else (cons (first arglist) (spread (next arglist)))))
385
+
386
+ (defn apply
387
+ "Applies fn f to the argument list formed by prepending args to argseq."
388
+ {:arglists '([f args* argseq])}
389
+ [#^clojure.lang.IFn f & args]
390
+ (. f (applyTo (spread args))))
391
+
392
+ (defn vary-meta
393
+ "Returns an object of the same type and value as obj, with
394
+ (apply f (meta obj) args) as its metadata."
395
+ [obj f & args]
396
+ (with-meta obj (apply f (meta obj) args)))
397
+
398
+ (defn list*
399
+ "Creates a new list containing the item prepended to more."
400
+ [item & more]
401
+ (spread (cons item more)))
402
+
403
+ (defmacro lazy-seq
404
+ "Takes a body of expressions that returns an ISeq or nil, and yields
405
+ a Seqable object that will invoke the body only the first time seq
406
+ is called, and will cache the result and return it on all subsequent
407
+ seq calls."
408
+ [& body]
409
+ (list 'new 'clojure.lang.LazySeq (list* '#^{:once true} fn* [] body)))
410
+
411
+ (defn concat
412
+ "Returns a lazy seq representing the concatenation of the elements in the supplied colls."
413
+ ([] (lazy-seq nil))
414
+ ([x] (lazy-seq x))
415
+ ([x y]
416
+ (lazy-seq
417
+ (let [s (seq x)]
418
+ (if s
419
+ (cons (first s) (concat (rest s) y))
420
+ y))))
421
+ ([x y & zs]
422
+ (let [cat (fn cat [xys zs]
423
+ (lazy-seq
424
+ (let [xys (seq xys)]
425
+ (if xys
426
+ (cons (first xys) (cat (rest xys) zs))
427
+ (when zs
428
+ (cat (first zs) (next zs)))))))]
429
+ (cat (concat x y) zs))))
430
+
431
+ ;;;;;;;;;;;;;;;;at this point all the support for syntax-quote exists;;;;;;;;;;;;;;;;;;;;;;
432
+
433
+
434
+ (defmacro delay
435
+ "Takes a body of expressions and yields a Delay object that will
436
+ invoke the body only the first time it is forced (with force), and
437
+ will cache the result and return it on all subsequent force
438
+ calls."
439
+ [& body]
440
+ (list 'new 'clojure.lang.Delay (list* `#^{:once true} fn* [] body)))
441
+
442
+ (defn delay?
443
+ "returns true if x is a Delay created with delay"
444
+ [x] (instance? clojure.lang.Delay x))
445
+
446
+ (defn force
447
+ "If x is a Delay, returns the (possibly cached) value of its expression, else returns x"
448
+ [x] (. clojure.lang.Delay (force x)))
449
+
450
+ (defmacro if-not
451
+ "Evaluates test. If logical false, evaluates and returns then expr, otherwise else expr, if supplied, else nil."
452
+ ([test then] `(if-not ~test ~then nil))
453
+ ([test then else]
454
+ `(if (not ~test) ~then ~else)))
455
+
456
+ (defn =
457
+ "Equality. Returns true if x equals y, false if not. Same as
458
+ Java x.equals(y) except it also works for nil, and compares
459
+ numbers and collections in a type-independent manner. Clojure's immutable data
460
+ structures define equals() (and thus =) as a value, not an identity,
461
+ comparison."
462
+ {:tag Boolean
463
+ :inline (fn [x y] `(. clojure.lang.Util equiv ~x ~y))
464
+ :inline-arities #{2}}
465
+ ([x] true)
466
+ ([x y] (clojure.lang.Util/equiv x y))
467
+ ([x y & more]
468
+ (if (= x y)
469
+ (if (next more)
470
+ (recur y (first more) (next more))
471
+ (= y (first more)))
472
+ false)))
473
+
474
+ (defn not=
475
+ "Same as (not (= obj1 obj2))"
476
+ {:tag Boolean}
477
+ ([x] false)
478
+ ([x y] (not (= x y)))
479
+ ([x y & more]
480
+ (not (apply = x y more))))
481
+
482
+
483
+
484
+ (defn compare
485
+ "Comparator. Returns 0 if x equals y, -1 if x is logically 'less
486
+ than' y, else 1. Same as Java x.compareTo(y) except it also works
487
+ for nil, and compares numbers and collections in a type-independent
488
+ manner. x must implement Comparable"
489
+ {:tag Integer
490
+ :inline (fn [x y] `(. clojure.lang.Util compare ~x ~y))}
491
+ [x y] (. clojure.lang.Util (compare x y)))
492
+
493
+ (defmacro and
494
+ "Evaluates exprs one at a time, from left to right. If a form
495
+ returns logical false (nil or false), and returns that value and
496
+ doesn't evaluate any of the other expressions, otherwise it returns
497
+ the value of the last expr. (and) returns true."
498
+ ([] true)
499
+ ([x] x)
500
+ ([x & next]
501
+ `(let [and# ~x]
502
+ (if and# (and ~@next) and#))))
503
+
504
+ (defmacro or
505
+ "Evaluates exprs one at a time, from left to right. If a form
506
+ returns a logical true value, or returns that value and doesn't
507
+ evaluate any of the other expressions, otherwise it returns the
508
+ value of the last expression. (or) returns nil."
509
+ ([] nil)
510
+ ([x] x)
511
+ ([x & next]
512
+ `(let [or# ~x]
513
+ (if or# or# (or ~@next)))))
514
+
515
+ ;;;;;;;;;;;;;;;;;;; sequence fns ;;;;;;;;;;;;;;;;;;;;;;;
516
+ (defn reduce
517
+ "f should be a function of 2 arguments. If val is not supplied,
518
+ returns the result of applying f to the first 2 items in coll, then
519
+ applying f to that result and the 3rd item, etc. If coll contains no
520
+ items, f must accept no arguments as well, and reduce returns the
521
+ result of calling f with no arguments. If coll has only 1 item, it
522
+ is returned and f is not called. If val is supplied, returns the
523
+ result of applying f to val and the first item in coll, then
524
+ applying f to that result and the 2nd item, etc. If coll contains no
525
+ items, returns val and f is not called."
526
+ ([f coll]
527
+ (let [s (seq coll)]
528
+ (if s
529
+ (if (instance? clojure.lang.IReduce s)
530
+ (. #^clojure.lang.IReduce s (reduce f))
531
+ (reduce f (first s) (next s)))
532
+ (f))))
533
+ ([f val coll]
534
+ (let [s (seq coll)]
535
+ (if (instance? clojure.lang.IReduce s)
536
+ (. #^clojure.lang.IReduce s (reduce f val))
537
+ ((fn [f val s]
538
+ (if s
539
+ (recur f (f val (first s)) (next s))
540
+ val))
541
+ f val s)))))
542
+
543
+ (defn reverse
544
+ "Returns a seq of the items in coll in reverse order. Not lazy."
545
+ [coll]
546
+ (reduce conj () coll))
547
+
548
+ ;;math stuff
549
+ (defn +
550
+ "Returns the sum of nums. (+) returns 0."
551
+ {:inline (fn [x y] `(. clojure.lang.Numbers (add ~x ~y)))
552
+ :inline-arities #{2}}
553
+ ([] 0)
554
+ ([x] (cast Number x))
555
+ ([x y] (. clojure.lang.Numbers (add x y)))
556
+ ([x y & more]
557
+ (reduce + (+ x y) more)))
558
+
559
+ (defn *
560
+ "Returns the product of nums. (*) returns 1."
561
+ {:inline (fn [x y] `(. clojure.lang.Numbers (multiply ~x ~y)))
562
+ :inline-arities #{2}}
563
+ ([] 1)
564
+ ([x] (cast Number x))
565
+ ([x y] (. clojure.lang.Numbers (multiply x y)))
566
+ ([x y & more]
567
+ (reduce * (* x y) more)))
568
+
569
+ (defn /
570
+ "If no denominators are supplied, returns 1/numerator,
571
+ else returns numerator divided by all of the denominators."
572
+ {:inline (fn [x y] `(. clojure.lang.Numbers (divide ~x ~y)))
573
+ :inline-arities #{2}}
574
+ ([x] (/ 1 x))
575
+ ([x y] (. clojure.lang.Numbers (divide x y)))
576
+ ([x y & more]
577
+ (reduce / (/ x y) more)))
578
+
579
+ (defn -
580
+ "If no ys are supplied, returns the negation of x, else subtracts
581
+ the ys from x and returns the result."
582
+ {:inline (fn [& args] `(. clojure.lang.Numbers (minus ~@args)))
583
+ :inline-arities #{1 2}}
584
+ ([x] (. clojure.lang.Numbers (minus x)))
585
+ ([x y] (. clojure.lang.Numbers (minus x y)))
586
+ ([x y & more]
587
+ (reduce - (- x y) more)))
588
+
589
+ (defn <
590
+ "Returns non-nil if nums are in monotonically increasing order,
591
+ otherwise false."
592
+ {:inline (fn [x y] `(. clojure.lang.Numbers (lt ~x ~y)))
593
+ :inline-arities #{2}}
594
+ ([x] true)
595
+ ([x y] (. clojure.lang.Numbers (lt x y)))
596
+ ([x y & more]
597
+ (if (< x y)
598
+ (if (next more)
599
+ (recur y (first more) (next more))
600
+ (< y (first more)))
601
+ false)))
602
+
603
+ (defn <=
604
+ "Returns non-nil if nums are in monotonically non-decreasing order,
605
+ otherwise false."
606
+ {:inline (fn [x y] `(. clojure.lang.Numbers (lte ~x ~y)))
607
+ :inline-arities #{2}}
608
+ ([x] true)
609
+ ([x y] (. clojure.lang.Numbers (lte x y)))
610
+ ([x y & more]
611
+ (if (<= x y)
612
+ (if (next more)
613
+ (recur y (first more) (next more))
614
+ (<= y (first more)))
615
+ false)))
616
+
617
+ (defn >
618
+ "Returns non-nil if nums are in monotonically decreasing order,
619
+ otherwise false."
620
+ {:inline (fn [x y] `(. clojure.lang.Numbers (gt ~x ~y)))
621
+ :inline-arities #{2}}
622
+ ([x] true)
623
+ ([x y] (. clojure.lang.Numbers (gt x y)))
624
+ ([x y & more]
625
+ (if (> x y)
626
+ (if (next more)
627
+ (recur y (first more) (next more))
628
+ (> y (first more)))
629
+ false)))
630
+
631
+ (defn >=
632
+ "Returns non-nil if nums are in monotonically non-increasing order,
633
+ otherwise false."
634
+ {:inline (fn [x y] `(. clojure.lang.Numbers (gte ~x ~y)))
635
+ :inline-arities #{2}}
636
+ ([x] true)
637
+ ([x y] (. clojure.lang.Numbers (gte x y)))
638
+ ([x y & more]
639
+ (if (>= x y)
640
+ (if (next more)
641
+ (recur y (first more) (next more))
642
+ (>= y (first more)))
643
+ false)))
644
+
645
+ (defn ==
646
+ "Returns non-nil if nums all have the same value, otherwise false"
647
+ {:inline (fn [x y] `(. clojure.lang.Numbers (equiv ~x ~y)))
648
+ :inline-arities #{2}}
649
+ ([x] true)
650
+ ([x y] (. clojure.lang.Numbers (equiv x y)))
651
+ ([x y & more]
652
+ (if (== x y)
653
+ (if (next more)
654
+ (recur y (first more) (next more))
655
+ (== y (first more)))
656
+ false)))
657
+
658
+ (defn max
659
+ "Returns the greatest of the nums."
660
+ ([x] x)
661
+ ([x y] (if (> x y) x y))
662
+ ([x y & more]
663
+ (reduce max (max x y) more)))
664
+
665
+ (defn min
666
+ "Returns the least of the nums."
667
+ ([x] x)
668
+ ([x y] (if (< x y) x y))
669
+ ([x y & more]
670
+ (reduce min (min x y) more)))
671
+
672
+ (defn inc
673
+ "Returns a number one greater than num."
674
+ {:inline (fn [x] `(. clojure.lang.Numbers (inc ~x)))}
675
+ [x] (. clojure.lang.Numbers (inc x)))
676
+
677
+ (defn dec
678
+ "Returns a number one less than num."
679
+ {:inline (fn [x] `(. clojure.lang.Numbers (dec ~x)))}
680
+ [x] (. clojure.lang.Numbers (dec x)))
681
+
682
+ (defn unchecked-inc
683
+ "Returns a number one greater than x, an int or long.
684
+ Note - uses a primitive operator subject to overflow."
685
+ {:inline (fn [x] `(. clojure.lang.Numbers (unchecked_inc ~x)))}
686
+ [x] (. clojure.lang.Numbers (unchecked_inc x)))
687
+
688
+ (defn unchecked-dec
689
+ "Returns a number one less than x, an int or long.
690
+ Note - uses a primitive operator subject to overflow."
691
+ {:inline (fn [x] `(. clojure.lang.Numbers (unchecked_dec ~x)))}
692
+ [x] (. clojure.lang.Numbers (unchecked_dec x)))
693
+
694
+ (defn unchecked-negate
695
+ "Returns the negation of x, an int or long.
696
+ Note - uses a primitive operator subject to overflow."
697
+ {:inline (fn [x] `(. clojure.lang.Numbers (unchecked_negate ~x)))}
698
+ [x] (. clojure.lang.Numbers (unchecked_negate x)))
699
+
700
+ (defn unchecked-add
701
+ "Returns the sum of x and y, both int or long.
702
+ Note - uses a primitive operator subject to overflow."
703
+ {:inline (fn [x y] `(. clojure.lang.Numbers (unchecked_add ~x ~y)))}
704
+ [x y] (. clojure.lang.Numbers (unchecked_add x y)))
705
+
706
+ (defn unchecked-subtract
707
+ "Returns the difference of x and y, both int or long.
708
+ Note - uses a primitive operator subject to overflow."
709
+ {:inline (fn [x y] `(. clojure.lang.Numbers (unchecked_subtract ~x ~y)))}
710
+ [x y] (. clojure.lang.Numbers (unchecked_subtract x y)))
711
+
712
+ (defn unchecked-multiply
713
+ "Returns the product of x and y, both int or long.
714
+ Note - uses a primitive operator subject to overflow."
715
+ {:inline (fn [x y] `(. clojure.lang.Numbers (unchecked_multiply ~x ~y)))}
716
+ [x y] (. clojure.lang.Numbers (unchecked_multiply x y)))
717
+
718
+ (defn unchecked-divide
719
+ "Returns the division of x by y, both int or long.
720
+ Note - uses a primitive operator subject to truncation."
721
+ {:inline (fn [x y] `(. clojure.lang.Numbers (unchecked_divide ~x ~y)))}
722
+ [x y] (. clojure.lang.Numbers (unchecked_divide x y)))
723
+
724
+ (defn unchecked-remainder
725
+ "Returns the remainder of division of x by y, both int or long.
726
+ Note - uses a primitive operator subject to truncation."
727
+ {:inline (fn [x y] `(. clojure.lang.Numbers (unchecked_remainder ~x ~y)))}
728
+ [x y] (. clojure.lang.Numbers (unchecked_remainder x y)))
729
+
730
+ (defn pos?
731
+ "Returns true if num is greater than zero, else false"
732
+ {:tag Boolean
733
+ :inline (fn [x] `(. clojure.lang.Numbers (isPos ~x)))}
734
+ [x] (. clojure.lang.Numbers (isPos x)))
735
+
736
+ (defn neg?
737
+ "Returns true if num is less than zero, else false"
738
+ {:tag Boolean
739
+ :inline (fn [x] `(. clojure.lang.Numbers (isNeg ~x)))}
740
+ [x] (. clojure.lang.Numbers (isNeg x)))
741
+
742
+ (defn zero?
743
+ "Returns true if num is zero, else false"
744
+ {:tag Boolean
745
+ :inline (fn [x] `(. clojure.lang.Numbers (isZero ~x)))}
746
+ [x] (. clojure.lang.Numbers (isZero x)))
747
+
748
+ (defn quot
749
+ "quot[ient] of dividing numerator by denominator."
750
+ [num div]
751
+ (. clojure.lang.Numbers (quotient num div)))
752
+
753
+ (defn rem
754
+ "remainder of dividing numerator by denominator."
755
+ [num div]
756
+ (. clojure.lang.Numbers (remainder num div)))
757
+
758
+ (defn rationalize
759
+ "returns the rational value of num"
760
+ [num]
761
+ (. clojure.lang.Numbers (rationalize num)))
762
+
763
+ ;;Bit ops
764
+
765
+ (defn bit-not
766
+ "Bitwise complement"
767
+ {:inline (fn [x] `(. clojure.lang.Numbers (not ~x)))}
768
+ [x] (. clojure.lang.Numbers not x))
769
+
770
+
771
+ (defn bit-and
772
+ "Bitwise and"
773
+ {:inline (fn [x y] `(. clojure.lang.Numbers (and ~x ~y)))}
774
+ [x y] (. clojure.lang.Numbers and x y))
775
+
776
+ (defn bit-or
777
+ "Bitwise or"
778
+ {:inline (fn [x y] `(. clojure.lang.Numbers (or ~x ~y)))}
779
+ [x y] (. clojure.lang.Numbers or x y))
780
+
781
+ (defn bit-xor
782
+ "Bitwise exclusive or"
783
+ {:inline (fn [x y] `(. clojure.lang.Numbers (xor ~x ~y)))}
784
+ [x y] (. clojure.lang.Numbers xor x y))
785
+
786
+ (defn bit-and-not
787
+ "Bitwise and with complement"
788
+ [x y] (. clojure.lang.Numbers andNot x y))
789
+
790
+
791
+ (defn bit-clear
792
+ "Clear bit at index n"
793
+ [x n] (. clojure.lang.Numbers clearBit x n))
794
+
795
+ (defn bit-set
796
+ "Set bit at index n"
797
+ [x n] (. clojure.lang.Numbers setBit x n))
798
+
799
+ (defn bit-flip
800
+ "Flip bit at index n"
801
+ [x n] (. clojure.lang.Numbers flipBit x n))
802
+
803
+ (defn bit-test
804
+ "Test bit at index n"
805
+ [x n] (. clojure.lang.Numbers testBit x n))
806
+
807
+
808
+ (defn bit-shift-left
809
+ "Bitwise shift left"
810
+ [x n] (. clojure.lang.Numbers shiftLeft x n))
811
+
812
+ (defn bit-shift-right
813
+ "Bitwise shift right"
814
+ [x n] (. clojure.lang.Numbers shiftRight x n))
815
+
816
+ (defn even?
817
+ "Returns true if n is even, throws an exception if n is not an integer"
818
+ [n] (zero? (bit-and n 1)))
819
+
820
+ (defn odd?
821
+ "Returns true if n is odd, throws an exception if n is not an integer"
822
+ [n] (not (even? n)))
823
+
824
+
825
+ ;;
826
+
827
+ (defn complement
828
+ "Takes a fn f and returns a fn that takes the same arguments as f,
829
+ has the same effects, if any, and returns the opposite truth value."
830
+ [f]
831
+ (fn
832
+ ([] (not (f)))
833
+ ([x] (not (f x)))
834
+ ([x y] (not (f x y)))
835
+ ([x y & zs] (not (apply f x y zs)))))
836
+
837
+ (defn constantly
838
+ "Returns a function that takes any number of arguments and returns x."
839
+ [x] (fn [& args] x))
840
+
841
+ (defn identity
842
+ "Returns its argument."
843
+ [x] x)
844
+
845
+ ;;Collection stuff
846
+
847
+
848
+
849
+ (defn count
850
+ "Returns the number of items in the collection. (count nil) returns
851
+ 0. Also works on strings, arrays, and Java Collections and Maps"
852
+ [coll] (. clojure.lang.RT (count coll)))
853
+
854
+ ;;list stuff
855
+ (defn peek
856
+ "For a list or queue, same as first, for a vector, same as, but much
857
+ more efficient than, last. If the collection is empty, returns nil."
858
+ [coll] (. clojure.lang.RT (peek coll)))
859
+
860
+ (defn pop
861
+ "For a list or queue, returns a new list/queue without the first
862
+ item, for a vector, returns a new vector without the last item. If
863
+ the collection is empty, throws an exception. Note - not the same
864
+ as next/butlast."
865
+ [coll] (. clojure.lang.RT (pop coll)))
866
+
867
+ (defn nth
868
+ "Returns the value at the index. get returns nil if index out of
869
+ bounds, nth throws an exception unless not-found is supplied. nth
870
+ also works for strings, Java arrays, regex Matchers and Lists, and,
871
+ in O(n) time, for sequences."
872
+ ([coll index] (. clojure.lang.RT (nth coll index)))
873
+ ([coll index not-found] (. clojure.lang.RT (nth coll index not-found))))
874
+
875
+ ;;map stuff
876
+
877
+ (defn contains?
878
+ "Returns true if key is present in the given collection, otherwise
879
+ returns false. Note that for numerically indexed collections like
880
+ vectors and Java arrays, this tests if the numeric key is within the
881
+ range of indexes. 'contains?' operates constant or logarithmic time;
882
+ it will not perform a linear search for a value. See also 'some'."
883
+ [coll key] (. clojure.lang.RT (contains coll key)))
884
+
885
+ (defn get
886
+ "Returns the value mapped to key, not-found or nil if key not present."
887
+ ([map key]
888
+ (. clojure.lang.RT (get map key)))
889
+ ([map key not-found]
890
+ (. clojure.lang.RT (get map key not-found))))
891
+
892
+ (defn dissoc
893
+ "dissoc[iate]. Returns a new map of the same (hashed/sorted) type,
894
+ that does not contain a mapping for key(s)."
895
+ ([map] map)
896
+ ([map key]
897
+ (. clojure.lang.RT (dissoc map key)))
898
+ ([map key & ks]
899
+ (let [ret (dissoc map key)]
900
+ (if ks
901
+ (recur ret (first ks) (next ks))
902
+ ret))))
903
+
904
+ (defn disj
905
+ "disj[oin]. Returns a new set of the same (hashed/sorted) type, that
906
+ does not contain key(s)."
907
+ ([set] set)
908
+ ([#^clojure.lang.IPersistentSet set key]
909
+ (. set (disjoin key)))
910
+ ([set key & ks]
911
+ (let [ret (disj set key)]
912
+ (if ks
913
+ (recur ret (first ks) (next ks))
914
+ ret))))
915
+
916
+ (defn find
917
+ "Returns the map entry for key, or nil if key not present."
918
+ [map key] (. clojure.lang.RT (find map key)))
919
+
920
+ (defn select-keys
921
+ "Returns a map containing only those entries in map whose key is in keys"
922
+ [map keyseq]
923
+ (loop [ret {} keys (seq keyseq)]
924
+ (if keys
925
+ (let [entry (. clojure.lang.RT (find map (first keys)))]
926
+ (recur
927
+ (if entry
928
+ (conj ret entry)
929
+ ret)
930
+ (next keys)))
931
+ ret)))
932
+
933
+ (defn keys
934
+ "Returns a sequence of the map's keys."
935
+ [map] (. clojure.lang.RT (keys map)))
936
+
937
+ (defn vals
938
+ "Returns a sequence of the map's values."
939
+ [map] (. clojure.lang.RT (vals map)))
940
+
941
+ (defn key
942
+ "Returns the key of the map entry."
943
+ [#^java.util.Map$Entry e]
944
+ (. e (getKey)))
945
+
946
+ (defn val
947
+ "Returns the value in the map entry."
948
+ [#^java.util.Map$Entry e]
949
+ (. e (getValue)))
950
+
951
+ (defn rseq
952
+ "Returns, in constant time, a seq of the items in rev (which
953
+ can be a vector or sorted-map), in reverse order. If rev is empty returns nil"
954
+ [#^clojure.lang.Reversible rev]
955
+ (. rev (rseq)))
956
+
957
+ (defn name
958
+ "Returns the name String of a symbol or keyword."
959
+ {:tag String}
960
+ [#^clojure.lang.Named x]
961
+ (. x (getName)))
962
+
963
+ (defn namespace
964
+ "Returns the namespace String of a symbol or keyword, or nil if not present."
965
+ {:tag String}
966
+ [#^clojure.lang.Named x]
967
+ (. x (getNamespace)))
968
+
969
+ (defmacro locking
970
+ "Executes exprs in an implicit do, while holding the monitor of x.
971
+ Will release the monitor of x in all circumstances."
972
+ [x & body]
973
+ `(let [lockee# ~x]
974
+ (try
975
+ (monitor-enter lockee#)
976
+ ~@body
977
+ (finally
978
+ (monitor-exit lockee#)))))
979
+
980
+ (defmacro ..
981
+ "form => fieldName-symbol or (instanceMethodName-symbol args*)
982
+
983
+ Expands into a member access (.) of the first member on the first
984
+ argument, followed by the next member on the result, etc. For
985
+ instance:
986
+
987
+ (.. System (getProperties) (get \"os.name\"))
988
+
989
+ expands to:
990
+
991
+ (. (. System (getProperties)) (get \"os.name\"))
992
+
993
+ but is easier to write, read, and understand."
994
+ ([x form] `(. ~x ~form))
995
+ ([x form & more] `(.. (. ~x ~form) ~@more)))
996
+
997
+ (defmacro ->
998
+ "Threads the expr through the forms. Inserts x as the
999
+ second item in the first form, making a list of it if it is not a
1000
+ list already. If there are more forms, inserts the first form as the
1001
+ second item in second form, etc."
1002
+ ([x form] (if (seq? form)
1003
+ `(~(first form) ~x ~@(next form))
1004
+ (list form x)))
1005
+ ([x form & more] `(-> (-> ~x ~form) ~@more)))
1006
+
1007
+ ;;multimethods
1008
+ (def global-hierarchy)
1009
+
1010
+ (defmacro defmulti
1011
+ "Creates a new multimethod with the associated dispatch function.
1012
+ The docstring and attribute-map are optional.
1013
+
1014
+ Options are key-value pairs and may be one of:
1015
+ :default the default dispatch value, defaults to :default
1016
+ :hierarchy the isa? hierarchy to use for dispatching
1017
+ defaults to the global hierarchy"
1018
+ {:arglists '([name docstring? attr-map? dispatch-fn & options])}
1019
+ [mm-name & options]
1020
+ (let [docstring (if (string? (first options))
1021
+ (first options)
1022
+ nil)
1023
+ options (if (string? (first options))
1024
+ (next options)
1025
+ options)
1026
+ m (if (map? (first options))
1027
+ (first options)
1028
+ {})
1029
+ options (if (map? (first options))
1030
+ (next options)
1031
+ options)
1032
+ dispatch-fn (first options)
1033
+ options (next options)
1034
+ m (assoc m :tag 'clojure.lang.MultiFn)
1035
+ m (if docstring
1036
+ (assoc m :doc docstring)
1037
+ m)
1038
+ m (if (meta mm-name)
1039
+ (conj (meta mm-name) m)
1040
+ m)]
1041
+ (when (= (count options) 1)
1042
+ (throw (Exception. "The syntax for defmulti has changed. Example: (defmulti name dispatch-fn :default dispatch-value)")))
1043
+ (let [options (apply hash-map options)
1044
+ default (get options :default :default)
1045
+ hierarchy (get options :hierarchy #'global-hierarchy)]
1046
+ `(def ~(with-meta mm-name m)
1047
+ (new clojure.lang.MultiFn ~(name mm-name) ~dispatch-fn ~default ~hierarchy)))))
1048
+
1049
+ (defmacro defmethod
1050
+ "Creates and installs a new method of multimethod associated with dispatch-value. "
1051
+ [multifn dispatch-val & fn-tail]
1052
+ `(. ~multifn addMethod ~dispatch-val (fn ~@fn-tail)))
1053
+
1054
+ (defn remove-method
1055
+ "Removes the method of multimethod associated with dispatch-value."
1056
+ [#^clojure.lang.MultiFn multifn dispatch-val]
1057
+ (. multifn removeMethod dispatch-val))
1058
+
1059
+ (defn prefer-method
1060
+ "Causes the multimethod to prefer matches of dispatch-val-x over dispatch-val-y when there is a conflict"
1061
+ [#^clojure.lang.MultiFn multifn dispatch-val-x dispatch-val-y]
1062
+ (. multifn preferMethod dispatch-val-x dispatch-val-y))
1063
+
1064
+ (defn methods
1065
+ "Given a multimethod, returns a map of dispatch values -> dispatch fns"
1066
+ [#^clojure.lang.MultiFn multifn] (.getMethodTable multifn))
1067
+
1068
+ (defn get-method
1069
+ "Given a multimethod and a dispatch value, returns the dispatch fn
1070
+ that would apply to that value, or nil if none apply and no default"
1071
+ [#^clojure.lang.MultiFn multifn dispatch-val] (.getMethod multifn dispatch-val))
1072
+
1073
+ (defn prefers
1074
+ "Given a multimethod, returns a map of preferred value -> set of other values"
1075
+ [#^clojure.lang.MultiFn multifn] (.getPreferTable multifn))
1076
+
1077
+ ;;;;;;;;; var stuff
1078
+
1079
+ (defmacro #^{:private true} assert-args [fnname & pairs]
1080
+ `(do (when-not ~(first pairs)
1081
+ (throw (IllegalArgumentException.
1082
+ ~(str fnname " requires " (second pairs)))))
1083
+ ~(let [more (nnext pairs)]
1084
+ (when more
1085
+ (list* `assert-args fnname more)))))
1086
+
1087
+ (defmacro if-let
1088
+ "bindings => binding-form test
1089
+
1090
+ If test is true, evaluates then with binding-form bound to the value of test, if not, yields else"
1091
+ ([bindings then]
1092
+ `(if-let ~bindings ~then nil))
1093
+ ([bindings then else & oldform]
1094
+ (assert-args if-let
1095
+ (and (vector? bindings) (nil? oldform)) "a vector for its binding"
1096
+ (= 2 (count bindings)) "exactly 2 forms in binding vector")
1097
+ (let [form (bindings 0) tst (bindings 1)]
1098
+ `(let [temp# ~tst]
1099
+ (if temp#
1100
+ (let [~form temp#]
1101
+ ~then)
1102
+ ~else)))))
1103
+
1104
+ (defmacro when-let
1105
+ "bindings => binding-form test
1106
+
1107
+ When test is true, evaluates body with binding-form bound to the value of test"
1108
+ [bindings & body]
1109
+ (assert-args when-let
1110
+ (vector? bindings) "a vector for its binding"
1111
+ (= 2 (count bindings)) "exactly 2 forms in binding vector")
1112
+ (let [form (bindings 0) tst (bindings 1)]
1113
+ `(let [temp# ~tst]
1114
+ (when temp#
1115
+ (let [~form temp#]
1116
+ ~@body)))))
1117
+
1118
+ (defmacro binding
1119
+ "binding => var-symbol init-expr
1120
+
1121
+ Creates new bindings for the (already-existing) vars, with the
1122
+ supplied initial values, executes the exprs in an implicit do, then
1123
+ re-establishes the bindings that existed before."
1124
+ [bindings & body]
1125
+ (assert-args binding
1126
+ (vector? bindings) "a vector for its binding"
1127
+ (even? (count bindings)) "an even number of forms in binding vector")
1128
+ (let [var-ize (fn [var-vals]
1129
+ (loop [ret [] vvs (seq var-vals)]
1130
+ (if vvs
1131
+ (recur (conj (conj ret `(var ~(first vvs))) (second vvs))
1132
+ (next (next vvs)))
1133
+ (seq ret))))]
1134
+ `(do
1135
+ (. clojure.lang.Var (pushThreadBindings (hash-map ~@(var-ize bindings))))
1136
+ (try
1137
+ ~@body
1138
+ (finally
1139
+ (. clojure.lang.Var (popThreadBindings)))))))
1140
+
1141
+ (defn find-var
1142
+ "Returns the global var named by the namespace-qualified symbol, or
1143
+ nil if no var with that name."
1144
+ [sym] (. clojure.lang.Var (find sym)))
1145
+
1146
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Refs ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1147
+ (defn #^{:private true}
1148
+ setup-reference [#^clojure.lang.ARef r options]
1149
+ (let [opts (apply hash-map options)]
1150
+ (when (:meta opts)
1151
+ (.resetMeta r (:meta opts)))
1152
+ (when (:validator opts)
1153
+ (.setValidator r (:validator opts)))
1154
+ r))
1155
+
1156
+ (defn agent
1157
+ "Creates and returns an agent with an initial value of state and
1158
+ zero or more options (in any order):
1159
+
1160
+ :meta metadata-map
1161
+
1162
+ :validator validate-fn
1163
+
1164
+ If metadata-map is supplied, it will be come the metadata on the
1165
+ agent. validate-fn must be nil or a side-effect-free fn of one
1166
+ argument, which will be passed the intended new state on any state
1167
+ change. If the new state is unacceptable, the validate-fn should
1168
+ return false or throw an exception."
1169
+ ([state] (new clojure.lang.Agent state))
1170
+ ([state & options]
1171
+ (setup-reference (agent state) options)))
1172
+
1173
+ (defn send
1174
+ "Dispatch an action to an agent. Returns the agent immediately.
1175
+ Subsequently, in a thread from a thread pool, the state of the agent
1176
+ will be set to the value of:
1177
+
1178
+ (apply action-fn state-of-agent args)"
1179
+ [#^clojure.lang.Agent a f & args]
1180
+ (. a (dispatch f args false)))
1181
+
1182
+ (defn send-off
1183
+ "Dispatch a potentially blocking action to an agent. Returns the
1184
+ agent immediately. Subsequently, in a separate thread, the state of
1185
+ the agent will be set to the value of:
1186
+
1187
+ (apply action-fn state-of-agent args)"
1188
+ [#^clojure.lang.Agent a f & args]
1189
+ (. a (dispatch f args true)))
1190
+
1191
+ (defn release-pending-sends
1192
+ "Normally, actions sent directly or indirectly during another action
1193
+ are held until the action completes (changes the agent's
1194
+ state). This function can be used to dispatch any pending sent
1195
+ actions immediately. This has no impact on actions sent during a
1196
+ transaction, which are still held until commit. If no action is
1197
+ occurring, does nothing. Returns the number of actions dispatched."
1198
+ [] (clojure.lang.Agent/releasePendingSends))
1199
+
1200
+ (defn add-watch
1201
+ "Experimental.
1202
+ Adds a watch function to an agent/atom/var/ref reference. The watch
1203
+ fn must be a fn of 4 args: a key, the reference, its old-state, its
1204
+ new-state. Whenever the reference's state might have been changed,
1205
+ any registered watches will have their functions called. The watch fn
1206
+ will be called synchronously, on the agent's thread if an agent,
1207
+ before any pending sends if agent or ref. Note that an atom's or
1208
+ ref's state may have changed again prior to the fn call, so use
1209
+ old/new-state rather than derefing the reference. Note also that watch
1210
+ fns may be called from multiple threads simultaneously. Var watchers
1211
+ are triggered only by root binding changes, not thread-local
1212
+ set!s. Keys must be unique per reference, and can be used to remove
1213
+ the watch with remove-watch, but are otherwise considered opaque by
1214
+ the watch mechanism."
1215
+ [#^clojure.lang.IRef reference key fn] (.addWatch reference key fn))
1216
+
1217
+ (defn remove-watch
1218
+ "Experimental.
1219
+ Removes a watch (set by add-watch) from a reference"
1220
+ [#^clojure.lang.IRef reference key]
1221
+ (.removeWatch reference key))
1222
+
1223
+ (defn add-watcher
1224
+ "Experimental.
1225
+ Adds a watcher to an agent/atom/var/ref reference. The watcher must
1226
+ be an Agent, and the action a function of the agent's state and one
1227
+ additional arg, the reference. Whenever the reference's state
1228
+ changes, any registered watchers will have their actions
1229
+ sent. send-type must be one of :send or :send-off. The actions will
1230
+ be sent after the reference's state is changed. Var watchers are
1231
+ triggered only by root binding changes, not thread-local set!s"
1232
+ [#^clojure.lang.IRef reference send-type watcher-agent action-fn]
1233
+ (add-watch reference watcher-agent
1234
+ (fn [watcher-agent reference old-state new-state]
1235
+ (when-not (identical? old-state new-state)
1236
+ ((if (= send-type :send-off) send-off send)
1237
+ watcher-agent action-fn reference)))))
1238
+
1239
+ (defn remove-watcher
1240
+ "Experimental.
1241
+ Removes a watcher (set by add-watcher) from a reference"
1242
+ [reference watcher-agent]
1243
+ (remove-watch reference watcher-agent))
1244
+
1245
+ (defn agent-errors
1246
+ "Returns a sequence of the exceptions thrown during asynchronous
1247
+ actions of the agent."
1248
+ [#^clojure.lang.Agent a] (. a (getErrors)))
1249
+
1250
+ (defn clear-agent-errors
1251
+ "Clears any exceptions thrown during asynchronous actions of the
1252
+ agent, allowing subsequent actions to occur."
1253
+ [#^clojure.lang.Agent a] (. a (clearErrors)))
1254
+
1255
+ (defn shutdown-agents
1256
+ "Initiates a shutdown of the thread pools that back the agent
1257
+ system. Running actions will complete, but no new actions will be
1258
+ accepted"
1259
+ [] (. clojure.lang.Agent shutdown))
1260
+
1261
+ (defn ref
1262
+ "Creates and returns a Ref with an initial value of x and zero or
1263
+ more options (in any order):
1264
+
1265
+ :meta metadata-map
1266
+
1267
+ :validator validate-fn
1268
+
1269
+ If metadata-map is supplied, it will be come the metadata on the
1270
+ ref. validate-fn must be nil or a side-effect-free fn of one
1271
+ argument, which will be passed the intended new state on any state
1272
+ change. If the new state is unacceptable, the validate-fn should
1273
+ return false or throw an exception. validate-fn will be called on
1274
+ transaction commit, when all refs have their final values."
1275
+ ([x] (new clojure.lang.Ref x))
1276
+ ([x & options] (setup-reference (ref x) options)))
1277
+
1278
+ (defn deref
1279
+ "Also reader macro: @ref/@agent/@var/@atom/@delay/@future. Within a transaction,
1280
+ returns the in-transaction-value of ref, else returns the
1281
+ most-recently-committed value of ref. When applied to a var, agent
1282
+ or atom, returns its current state. When applied to a delay, forces
1283
+ it if not already forced. When applied to a future, will block if
1284
+ computation not complete"
1285
+ [#^clojure.lang.IDeref ref] (.deref ref))
1286
+
1287
+ (defn atom
1288
+ "Creates and returns an Atom with an initial value of x and zero or
1289
+ more options (in any order):
1290
+
1291
+ :meta metadata-map
1292
+
1293
+ :validator validate-fn
1294
+
1295
+ If metadata-map is supplied, it will be come the metadata on the
1296
+ atom. validate-fn must be nil or a side-effect-free fn of one
1297
+ argument, which will be passed the intended new state on any state
1298
+ change. If the new state is unacceptable, the validate-fn should
1299
+ return false or throw an exception."
1300
+ ([x] (new clojure.lang.Atom x))
1301
+ ([x & options] (setup-reference (atom x) options)))
1302
+
1303
+ (defn swap!
1304
+ "Atomically swaps the value of atom to be:
1305
+ (apply f current-value-of-atom args). Note that f may be called
1306
+ multiple times, and thus should be free of side effects. Returns
1307
+ the value that was swapped in."
1308
+ ([#^clojure.lang.Atom atom f] (.swap atom f))
1309
+ ([#^clojure.lang.Atom atom f x] (.swap atom f x))
1310
+ ([#^clojure.lang.Atom atom f x y] (.swap atom f x y))
1311
+ ([#^clojure.lang.Atom atom f x y & args] (.swap atom f x y args)))
1312
+
1313
+ (defn compare-and-set!
1314
+ "Atomically sets the value of atom to newval if and only if the
1315
+ current value of the atom is identical to oldval. Returns true if
1316
+ set happened, else false"
1317
+ [#^clojure.lang.Atom atom oldval newval] (.compareAndSet atom oldval newval))
1318
+
1319
+ (defn reset!
1320
+ "Sets the value of atom to newval without regard for the
1321
+ current value. Returns newval."
1322
+ [#^clojure.lang.Atom atom newval] (.reset atom newval))
1323
+
1324
+ (defn set-validator!
1325
+ "Sets the validator-fn for a var/ref/agent/atom. validator-fn must be nil or a
1326
+ side-effect-free fn of one argument, which will be passed the intended
1327
+ new state on any state change. If the new state is unacceptable, the
1328
+ validator-fn should return false or throw an exception. If the current state (root
1329
+ value if var) is not acceptable to the new validator, an exception
1330
+ will be thrown and the validator will not be changed."
1331
+ [#^clojure.lang.IRef iref validator-fn] (. iref (setValidator validator-fn)))
1332
+
1333
+ (defn get-validator
1334
+ "Gets the validator-fn for a var/ref/agent/atom."
1335
+ [#^clojure.lang.IRef iref] (. iref (getValidator)))
1336
+
1337
+ (defn alter-meta!
1338
+ "Atomically sets the metadata for a namespace/var/ref/agent/atom to be:
1339
+
1340
+ (apply f its-current-meta args)
1341
+
1342
+ f must be free of side-effects"
1343
+ [#^clojure.lang.IReference iref f & args] (.alterMeta iref f args))
1344
+
1345
+ (defn reset-meta!
1346
+ "Atomically resets the metadata for a namespace/var/ref/agent/atom"
1347
+ [#^clojure.lang.IReference iref metadata-map] (.resetMeta iref metadata-map))
1348
+
1349
+ (defn commute
1350
+ "Must be called in a transaction. Sets the in-transaction-value of
1351
+ ref to:
1352
+
1353
+ (apply fun in-transaction-value-of-ref args)
1354
+
1355
+ and returns the in-transaction-value of ref.
1356
+
1357
+ At the commit point of the transaction, sets the value of ref to be:
1358
+
1359
+ (apply fun most-recently-committed-value-of-ref args)
1360
+
1361
+ Thus fun should be commutative, or, failing that, you must accept
1362
+ last-one-in-wins behavior. commute allows for more concurrency than
1363
+ ref-set."
1364
+
1365
+ [#^clojure.lang.Ref ref fun & args]
1366
+ (. ref (commute fun args)))
1367
+
1368
+ (defn alter
1369
+ "Must be called in a transaction. Sets the in-transaction-value of
1370
+ ref to:
1371
+
1372
+ (apply fun in-transaction-value-of-ref args)
1373
+
1374
+ and returns the in-transaction-value of ref."
1375
+ [#^clojure.lang.Ref ref fun & args]
1376
+ (. ref (alter fun args)))
1377
+
1378
+ (defn ref-set
1379
+ "Must be called in a transaction. Sets the value of ref.
1380
+ Returns val."
1381
+ [#^clojure.lang.Ref ref val]
1382
+ (. ref (set val)))
1383
+
1384
+ (defn ensure
1385
+ "Must be called in a transaction. Protects the ref from modification
1386
+ by other transactions. Returns the in-transaction-value of
1387
+ ref. Allows for more concurrency than (ref-set ref @ref)"
1388
+ [#^clojure.lang.Ref ref]
1389
+ (. ref (touch))
1390
+ (. ref (deref)))
1391
+
1392
+ (defmacro sync
1393
+ "transaction-flags => TBD, pass nil for now
1394
+
1395
+ Runs the exprs (in an implicit do) in a transaction that encompasses
1396
+ exprs and any nested calls. Starts a transaction if none is already
1397
+ running on this thread. Any uncaught exception will abort the
1398
+ transaction and flow out of sync. The exprs may be run more than
1399
+ once, but any effects on Refs will be atomic."
1400
+ [flags-ignored-for-now & body]
1401
+ `(. clojure.lang.LockingTransaction
1402
+ (runInTransaction (fn [] ~@body))))
1403
+
1404
+
1405
+ (defmacro io!
1406
+ "If an io! block occurs in a transaction, throws an
1407
+ IllegalStateException, else runs body in an implicit do. If the
1408
+ first expression in body is a literal string, will use that as the
1409
+ exception message."
1410
+ [& body]
1411
+ (let [message (when (string? (first body)) (first body))
1412
+ body (if message (next body) body)]
1413
+ `(if (clojure.lang.LockingTransaction/isRunning)
1414
+ (throw (new IllegalStateException ~(or message "I/O in transaction")))
1415
+ (do ~@body))))
1416
+
1417
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; fn stuff ;;;;;;;;;;;;;;;;
1418
+
1419
+
1420
+ (defn comp
1421
+ "Takes a set of functions and returns a fn that is the composition
1422
+ of those fns. The returned fn takes a variable number of args,
1423
+ applies the rightmost of fns to the args, the next
1424
+ fn (right-to-left) to the result, etc."
1425
+ [& fs]
1426
+ (let [fs (reverse fs)]
1427
+ (fn [& args]
1428
+ (loop [ret (apply (first fs) args) fs (next fs)]
1429
+ (if fs
1430
+ (recur ((first fs) ret) (next fs))
1431
+ ret)))))
1432
+
1433
+ (defn partial
1434
+ "Takes a function f and fewer than the normal arguments to f, and
1435
+ returns a fn that takes a variable number of additional args. When
1436
+ called, the returned function calls f with args + additional args."
1437
+ ([f arg1]
1438
+ (fn [& args] (apply f arg1 args)))
1439
+ ([f arg1 arg2]
1440
+ (fn [& args] (apply f arg1 arg2 args)))
1441
+ ([f arg1 arg2 arg3]
1442
+ (fn [& args] (apply f arg1 arg2 arg3 args)))
1443
+ ([f arg1 arg2 arg3 & more]
1444
+ (fn [& args] (apply f arg1 arg2 arg3 (concat more args)))))
1445
+
1446
+ ;;;;;;;;;;;;;;;;;;; sequence fns ;;;;;;;;;;;;;;;;;;;;;;;
1447
+ (defn stream?
1448
+ "Returns true if x is an instance of Stream"
1449
+ [x] (instance? clojure.lang.Stream x))
1450
+
1451
+
1452
+ (defn sequence
1453
+ "Coerces coll to a (possibly empty) sequence, if it is not already
1454
+ one. Will not force a lazy seq. (sequence nil) yields ()"
1455
+ [coll]
1456
+ (cond
1457
+ (seq? coll) coll
1458
+ (stream? coll) (.sequence #^clojure.lang.Stream coll)
1459
+ :else (or (seq coll) ())))
1460
+
1461
+ (defn every?
1462
+ "Returns true if (pred x) is logical true for every x in coll, else
1463
+ false."
1464
+ {:tag Boolean}
1465
+ [pred coll]
1466
+ (if (seq coll)
1467
+ (and (pred (first coll))
1468
+ (recur pred (next coll)))
1469
+ true))
1470
+
1471
+ (def
1472
+ #^{:tag Boolean
1473
+ :doc "Returns false if (pred x) is logical true for every x in
1474
+ coll, else true."
1475
+ :arglists '([pred coll])}
1476
+ not-every? (comp not every?))
1477
+
1478
+ (defn some
1479
+ "Returns the first logical true value of (pred x) for any x in coll,
1480
+ else nil. One common idiom is to use a set as pred, for example
1481
+ this will return true if :fred is in the sequence, otherwise nil:
1482
+ (some #{:fred} coll)"
1483
+ [pred coll]
1484
+ (when (seq coll)
1485
+ (or (pred (first coll)) (recur pred (next coll)))))
1486
+
1487
+ (def
1488
+ #^{:tag Boolean
1489
+ :doc "Returns false if (pred x) is logical true for any x in coll,
1490
+ else true."
1491
+ :arglists '([pred coll])}
1492
+ not-any? (comp not some))
1493
+
1494
+ (defn map
1495
+ "Returns a lazy sequence consisting of the result of applying f to the
1496
+ set of first items of each coll, followed by applying f to the set
1497
+ of second items in each coll, until any one of the colls is
1498
+ exhausted. Any remaining items in other colls are ignored. Function
1499
+ f should accept number-of-colls arguments."
1500
+ ([f coll]
1501
+ (lazy-seq
1502
+ (when-let [s (seq coll)]
1503
+ (cons (f (first s)) (map f (rest s))))))
1504
+ ([f c1 c2]
1505
+ (lazy-seq
1506
+ (let [s1 (seq c1) s2 (seq c2)]
1507
+ (when (and s1 s2)
1508
+ (cons (f (first s1) (first s2))
1509
+ (map f (rest s1) (rest s2)))))))
1510
+ ([f c1 c2 c3]
1511
+ (lazy-seq
1512
+ (let [s1 (seq c1) s2 (seq c2) s3 (seq c3)]
1513
+ (when (and s1 s2 s3)
1514
+ (cons (f (first s1) (first s2) (first s3))
1515
+ (map f (rest s1) (rest s2) (rest s3)))))))
1516
+ ([f c1 c2 c3 & colls]
1517
+ (let [step (fn step [cs]
1518
+ (lazy-seq
1519
+ (let [ss (map seq cs)]
1520
+ (when (every? identity ss)
1521
+ (cons (map first ss) (step (map rest ss)))))))]
1522
+ (map #(apply f %) (step (conj colls c3 c2 c1))))))
1523
+
1524
+ (defn mapcat
1525
+ "Returns the result of applying concat to the result of applying map
1526
+ to f and colls. Thus function f should return a collection."
1527
+ [f & colls]
1528
+ (apply concat (apply map f colls)))
1529
+
1530
+ (defn filter
1531
+ "Returns a lazy sequence of the items in coll for which
1532
+ (pred item) returns true. pred must be free of side-effects."
1533
+ [pred coll]
1534
+ (let [step (fn [p c]
1535
+ (when-let [s (seq c)]
1536
+ (if (p (first s))
1537
+ (cons (first s) (filter p (rest s)))
1538
+ (recur p (rest s)))))]
1539
+ (lazy-seq (step pred coll))))
1540
+
1541
+
1542
+ (defn remove
1543
+ "Returns a lazy sequence of the items in coll for which
1544
+ (pred item) returns false. pred must be free of side-effects."
1545
+ [pred coll]
1546
+ (filter (complement pred) coll))
1547
+
1548
+ (defn take
1549
+ "Returns a lazy sequence of the first n items in coll, or all items if
1550
+ there are fewer than n."
1551
+ [n coll]
1552
+ (lazy-seq
1553
+ (when (pos? n)
1554
+ (when-let [s (seq coll)]
1555
+ (cons (first s) (take (dec n) (rest s)))))))
1556
+
1557
+ (defn take-while
1558
+ "Returns a lazy sequence of successive items from coll while
1559
+ (pred item) returns true. pred must be free of side-effects."
1560
+ [pred coll]
1561
+ (lazy-seq
1562
+ (when-let [s (seq coll)]
1563
+ (when (pred (first s))
1564
+ (cons (first s) (take-while pred (rest s)))))))
1565
+
1566
+ (defn drop
1567
+ "Returns a lazy sequence of all but the first n items in coll."
1568
+ [n coll]
1569
+ (let [step (fn [n coll]
1570
+ (let [s (seq coll)]
1571
+ (if (and (pos? n) s)
1572
+ (recur (dec n) (rest s))
1573
+ s)))]
1574
+ (lazy-seq (step n coll))))
1575
+
1576
+ (defn drop-last
1577
+ "Return a lazy sequence of all but the last n (default 1) items in coll"
1578
+ ([s] (drop-last 1 s))
1579
+ ([n s] (map (fn [x _] x) s (drop n s))))
1580
+
1581
+ (defn drop-while
1582
+ "Returns a lazy sequence of the items in coll starting from the first
1583
+ item for which (pred item) returns nil."
1584
+ [pred coll]
1585
+ (let [step (fn [pred coll]
1586
+ (let [s (seq coll)]
1587
+ (if (and s (pred (first s)))
1588
+ (recur pred (rest s))
1589
+ s)))]
1590
+ (lazy-seq (step pred coll))))
1591
+
1592
+ (defn cycle
1593
+ "Returns a lazy (infinite!) sequence of repetitions of the items in coll."
1594
+ [coll] (lazy-seq
1595
+ (when-let [s (seq coll)]
1596
+ (concat s (cycle s)))))
1597
+
1598
+ (defn split-at
1599
+ "Returns a vector of [(take n coll) (drop n coll)]"
1600
+ [n coll]
1601
+ [(take n coll) (drop n coll)])
1602
+
1603
+ (defn split-with
1604
+ "Returns a vector of [(take-while pred coll) (drop-while pred coll)]"
1605
+ [pred coll]
1606
+ [(take-while pred coll) (drop-while pred coll)])
1607
+
1608
+ (defn repeat
1609
+ "Returns a lazy (infinite!, or length n if supplied) sequence of xs."
1610
+ ([x] (lazy-seq (cons x (repeat x))))
1611
+ ([n x] (take n (repeat x))))
1612
+
1613
+ (defn replicate
1614
+ "Returns a lazy seq of n xs."
1615
+ [n x] (take n (repeat x)))
1616
+
1617
+ (defn iterate
1618
+ "Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of side-effects"
1619
+ [f x] (cons x (lazy-seq (iterate f (f x)))))
1620
+
1621
+ (defn range
1622
+ "Returns a lazy seq of nums from start (inclusive) to end
1623
+ (exclusive), by step, where start defaults to 0 and step to 1."
1624
+ ([end] (if (and (> end 0) (<= end (. Integer MAX_VALUE)))
1625
+ (new clojure.lang.Range 0 end)
1626
+ (take end (iterate inc 0))))
1627
+ ([start end] (if (and (< start end)
1628
+ (>= start (. Integer MIN_VALUE))
1629
+ (<= end (. Integer MAX_VALUE)))
1630
+ (new clojure.lang.Range start end)
1631
+ (take (- end start) (iterate inc start))))
1632
+ ([start end step]
1633
+ (take-while (partial (if (pos? step) > <) end) (iterate (partial + step) start))))
1634
+
1635
+ (defn merge
1636
+ "Returns a map that consists of the rest of the maps conj-ed onto
1637
+ the first. If a key occurs in more than one map, the mapping from
1638
+ the latter (left-to-right) will be the mapping in the result."
1639
+ [& maps]
1640
+ (when (some identity maps)
1641
+ (reduce #(conj (or %1 {}) %2) maps)))
1642
+
1643
+ (defn merge-with
1644
+ "Returns a map that consists of the rest of the maps conj-ed onto
1645
+ the first. If a key occurs in more than one map, the mapping(s)
1646
+ from the latter (left-to-right) will be combined with the mapping in
1647
+ the result by calling (f val-in-result val-in-latter)."
1648
+ [f & maps]
1649
+ (when (some identity maps)
1650
+ (let [merge-entry (fn [m e]
1651
+ (let [k (key e) v (val e)]
1652
+ (if (contains? m k)
1653
+ (assoc m k (f (m k) v))
1654
+ (assoc m k v))))
1655
+ merge2 (fn [m1 m2]
1656
+ (reduce merge-entry (or m1 {}) (seq m2)))]
1657
+ (reduce merge2 maps))))
1658
+
1659
+
1660
+
1661
+ (defn zipmap
1662
+ "Returns a map with the keys mapped to the corresponding vals."
1663
+ [keys vals]
1664
+ (loop [map {}
1665
+ ks (seq keys)
1666
+ vs (seq vals)]
1667
+ (if (and ks vs)
1668
+ (recur (assoc map (first ks) (first vs))
1669
+ (next ks)
1670
+ (next vs))
1671
+ map)))
1672
+
1673
+ (defn line-seq
1674
+ "Returns the lines of text from rdr as a lazy sequence of strings.
1675
+ rdr must implement java.io.BufferedReader."
1676
+ [#^java.io.BufferedReader rdr]
1677
+ (lazy-seq
1678
+ (let [line (. rdr (readLine))]
1679
+ (when line
1680
+ (cons line (line-seq rdr))))))
1681
+
1682
+ (defn comparator
1683
+ "Returns an implementation of java.util.Comparator based upon pred."
1684
+ [pred]
1685
+ (fn [x y]
1686
+ (cond (pred x y) -1 (pred y x) 1 :else 0)))
1687
+
1688
+ (defn sort
1689
+ "Returns a sorted sequence of the items in coll. If no comparator is
1690
+ supplied, uses compare. comparator must
1691
+ implement java.util.Comparator."
1692
+ ([coll]
1693
+ (sort compare coll))
1694
+ ([#^java.util.Comparator comp coll]
1695
+ (if (seq coll)
1696
+ (let [a (to-array coll)]
1697
+ (. java.util.Arrays (sort a comp))
1698
+ (seq a))
1699
+ ())))
1700
+
1701
+ (defn sort-by
1702
+ "Returns a sorted sequence of the items in coll, where the sort
1703
+ order is determined by comparing (keyfn item). If no comparator is
1704
+ supplied, uses compare. comparator must
1705
+ implement java.util.Comparator."
1706
+ ([keyfn coll]
1707
+ (sort-by keyfn compare coll))
1708
+ ([keyfn #^java.util.Comparator comp coll]
1709
+ (sort (fn [x y] (. comp (compare (keyfn x) (keyfn y)))) coll)))
1710
+
1711
+ (defn partition
1712
+ "Returns a lazy sequence of lists of n items each, at offsets step
1713
+ apart. If step is not supplied, defaults to n, i.e. the partitions
1714
+ do not overlap."
1715
+ ([n coll]
1716
+ (partition n n coll))
1717
+ ([n step coll]
1718
+ (lazy-seq
1719
+ (when-let [s (seq coll)]
1720
+ (let [p (take n s)]
1721
+ (when (= n (count p))
1722
+ (cons p (partition n step (drop step s)))))))))
1723
+
1724
+ ;; evaluation
1725
+
1726
+ (defn eval
1727
+ "Evaluates the form data structure (not text!) and returns the result."
1728
+ [form] (. clojure.lang.Compiler (eval form)))
1729
+
1730
+ (defmacro doseq
1731
+ "Repeatedly executes body (presumably for side-effects) with
1732
+ bindings and filtering as provided by \"for\". Does not retain
1733
+ the head of the sequence. Returns nil."
1734
+ [seq-exprs & body]
1735
+ (assert-args doseq
1736
+ (vector? seq-exprs) "a vector for its binding"
1737
+ (even? (count seq-exprs)) "an even number of forms in binding vector")
1738
+ (let [step (fn step [recform exprs]
1739
+ (if-not exprs
1740
+ [true `(do ~@body)]
1741
+ (let [k (first exprs)
1742
+ v (second exprs)
1743
+ seqsym (when-not (keyword? k) (gensym))
1744
+ recform (if (keyword? k) recform `(recur (next ~seqsym)))
1745
+ steppair (step recform (nnext exprs))
1746
+ needrec (steppair 0)
1747
+ subform (steppair 1)]
1748
+ (cond
1749
+ (= k :let) [needrec `(let ~v ~subform)]
1750
+ (= k :while) [false `(when ~v
1751
+ ~subform
1752
+ ~@(when needrec [recform]))]
1753
+ (= k :when) [false `(if ~v
1754
+ (do
1755
+ ~subform
1756
+ ~@(when needrec [recform]))
1757
+ ~recform)]
1758
+ :else [true `(loop [~seqsym (seq ~v)]
1759
+ (when ~seqsym
1760
+ (let [~k (first ~seqsym)]
1761
+ ~subform
1762
+ ~@(when needrec [recform]))))]))))]
1763
+ (nth (step nil (seq seq-exprs)) 1)))
1764
+
1765
+ (defn dorun
1766
+ "When lazy sequences are produced via functions that have side
1767
+ effects, any effects other than those needed to produce the first
1768
+ element in the seq do not occur until the seq is consumed. dorun can
1769
+ be used to force any effects. Walks through the successive nexts of
1770
+ the seq, does not retain the head and returns nil."
1771
+ ([coll]
1772
+ (when (seq coll)
1773
+ (recur (next coll))))
1774
+ ([n coll]
1775
+ (when (and (seq coll) (pos? n))
1776
+ (recur (dec n) (next coll)))))
1777
+
1778
+ (defn doall
1779
+ "When lazy sequences are produced via functions that have side
1780
+ effects, any effects other than those needed to produce the first
1781
+ element in the seq do not occur until the seq is consumed. doall can
1782
+ be used to force any effects. Walks through the successive nexts of
1783
+ the seq, retains the head and returns it, thus causing the entire
1784
+ seq to reside in memory at one time."
1785
+ ([coll]
1786
+ (dorun coll)
1787
+ coll)
1788
+ ([n coll]
1789
+ (dorun n coll)
1790
+ coll))
1791
+
1792
+ (defn await
1793
+ "Blocks the current thread (indefinitely!) until all actions
1794
+ dispatched thus far, from this thread or agent, to the agent(s) have
1795
+ occurred."
1796
+ [& agents]
1797
+ (io! "await in transaction"
1798
+ (when *agent*
1799
+ (throw (new Exception "Can't await in agent action")))
1800
+ (let [latch (new java.util.concurrent.CountDownLatch (count agents))
1801
+ count-down (fn [agent] (. latch (countDown)) agent)]
1802
+ (doseq [agent agents]
1803
+ (send agent count-down))
1804
+ (. latch (await)))))
1805
+
1806
+ (defn await1 [#^clojure.lang.Agent a]
1807
+ (when (pos? (.getQueueCount a))
1808
+ (await a))
1809
+ a)
1810
+
1811
+ (defn await-for
1812
+ "Blocks the current thread until all actions dispatched thus
1813
+ far (from this thread or agent) to the agents have occurred, or the
1814
+ timeout (in milliseconds) has elapsed. Returns nil if returning due
1815
+ to timeout, non-nil otherwise."
1816
+ [timeout-ms & agents]
1817
+ (io! "await-for in transaction"
1818
+ (when *agent*
1819
+ (throw (new Exception "Can't await in agent action")))
1820
+ (let [latch (new java.util.concurrent.CountDownLatch (count agents))
1821
+ count-down (fn [agent] (. latch (countDown)) agent)]
1822
+ (doseq [agent agents]
1823
+ (send agent count-down))
1824
+ (. latch (await timeout-ms (. java.util.concurrent.TimeUnit MILLISECONDS))))))
1825
+
1826
+ (defmacro dotimes
1827
+ "bindings => name n
1828
+
1829
+ Repeatedly executes body (presumably for side-effects) with name
1830
+ bound to integers from 0 through n-1."
1831
+ [bindings & body]
1832
+ (assert-args dotimes
1833
+ (vector? bindings) "a vector for its binding"
1834
+ (= 2 (count bindings)) "exactly 2 forms in binding vector")
1835
+ (let [i (first bindings)
1836
+ n (second bindings)]
1837
+ `(let [n# (int ~n)]
1838
+ (loop [~i (int 0)]
1839
+ (when (< ~i n#)
1840
+ ~@body
1841
+ (recur (unchecked-inc ~i)))))))
1842
+
1843
+ (defn import
1844
+ "import-list => (package-symbol class-name-symbols*)
1845
+
1846
+ For each name in class-name-symbols, adds a mapping from name to the
1847
+ class named by package.name to the current namespace. Use :import in the ns
1848
+ macro in preference to calling this directly."
1849
+ [& import-symbols-or-lists]
1850
+ (let [#^clojure.lang.Namespace ns *ns*]
1851
+ (doseq [spec import-symbols-or-lists]
1852
+ (if (symbol? spec)
1853
+ (let [n (name spec)
1854
+ dot (.lastIndexOf n (. clojure.lang.RT (intCast \.)))
1855
+ c (symbol (.substring n (inc dot)))]
1856
+ (. ns (importClass c (. clojure.lang.RT (classForName (name spec))))))
1857
+ (let [pkg (first spec)
1858
+ classes (next spec)]
1859
+ (doseq [c classes]
1860
+ (. ns (importClass c (. clojure.lang.RT (classForName (str pkg "." c)))))))))))
1861
+
1862
+
1863
+ (defn into-array
1864
+ "Returns an array with components set to the values in aseq. The array's
1865
+ component type is type if provided, or the type of the first value in
1866
+ aseq if present, or Object. All values in aseq must be compatible with
1867
+ the component type. Class objects for the primitive types can be obtained
1868
+ using, e.g., Integer/TYPE."
1869
+ ([aseq]
1870
+ (clojure.lang.RT/seqToTypedArray (seq aseq)))
1871
+ ([type aseq]
1872
+ (clojure.lang.RT/seqToTypedArray type (seq aseq))))
1873
+
1874
+ (defn into
1875
+ "Returns a new coll consisting of to-coll with all of the items of
1876
+ from-coll conjoined."
1877
+ [to from]
1878
+ (let [ret to items (seq from)]
1879
+ (if items
1880
+ (recur (conj ret (first items)) (next items))
1881
+ ret)))
1882
+
1883
+ (defn #^{:private true}
1884
+ array [& items]
1885
+ (into-array items))
1886
+
1887
+ (defn #^Class class
1888
+ "Returns the Class of x"
1889
+ [#^Object x] (if (nil? x) x (. x (getClass))))
1890
+
1891
+ (defn type
1892
+ "Returns the :type metadata of x, or its Class if none"
1893
+ [x]
1894
+ (or (:type (meta x)) (class x)))
1895
+
1896
+ (defn num
1897
+ "Coerce to Number"
1898
+ {:tag Number
1899
+ :inline (fn [x] `(. clojure.lang.Numbers (num ~x)))}
1900
+ [x] (. clojure.lang.Numbers (num x)))
1901
+
1902
+ (defn int
1903
+ "Coerce to int"
1904
+ {:tag Integer
1905
+ :inline (fn [x] `(. clojure.lang.RT (intCast ~x)))}
1906
+ [x] (. clojure.lang.RT (intCast x)))
1907
+
1908
+ (defn long
1909
+ "Coerce to long"
1910
+ {:tag Long
1911
+ :inline (fn [x] `(. clojure.lang.RT (longCast ~x)))}
1912
+ [#^Number x] (. x (longValue)))
1913
+
1914
+ (defn float
1915
+ "Coerce to float"
1916
+ {:tag Float
1917
+ :inline (fn [x] `(. clojure.lang.RT (floatCast ~x)))}
1918
+ [#^Number x] (. x (floatValue)))
1919
+
1920
+ (defn double
1921
+ "Coerce to double"
1922
+ {:tag Double
1923
+ :inline (fn [x] `(. clojure.lang.RT (doubleCast ~x)))}
1924
+ [#^Number x] (. x (doubleValue)))
1925
+
1926
+ (defn short
1927
+ "Coerce to short"
1928
+ {:tag Short
1929
+ :inline (fn [x] `(. clojure.lang.RT (shortCast ~x)))}
1930
+ [#^Number x] (. x (shortValue)))
1931
+
1932
+ (defn byte
1933
+ "Coerce to byte"
1934
+ {:tag Byte
1935
+ :inline (fn [x] `(. clojure.lang.RT (byteCast ~x)))}
1936
+ [#^Number x] (. x (byteValue)))
1937
+
1938
+ (defn char
1939
+ "Coerce to char"
1940
+ {:tag Character
1941
+ :inline (fn [x] `(. clojure.lang.RT (charCast ~x)))}
1942
+ [x] (. clojure.lang.RT (charCast x)))
1943
+
1944
+ (defn boolean
1945
+ "Coerce to boolean"
1946
+ {:tag Boolean
1947
+ :inline (fn [x] `(. clojure.lang.RT (booleanCast ~x)))}
1948
+ [x] (if x true false))
1949
+
1950
+ (defn number?
1951
+ "Returns true if x is a Number"
1952
+ [x]
1953
+ (instance? Number x))
1954
+
1955
+ (defn integer?
1956
+ "Returns true if n is an integer"
1957
+ [n]
1958
+ (or (instance? Integer n)
1959
+ (instance? Long n)
1960
+ (instance? BigInteger n)
1961
+ (instance? Short n)
1962
+ (instance? Byte n)))
1963
+
1964
+ (defn mod
1965
+ "Modulus of num and div. Truncates toward negative infinity."
1966
+ [num div]
1967
+ (let [m (rem num div)]
1968
+ (if (or (zero? m) (pos? (* num div)))
1969
+ m
1970
+ (+ m div))))
1971
+
1972
+ (defn ratio?
1973
+ "Returns true if n is a Ratio"
1974
+ [n] (instance? clojure.lang.Ratio n))
1975
+
1976
+ (defn decimal?
1977
+ "Returns true if n is a BigDecimal"
1978
+ [n] (instance? BigDecimal n))
1979
+
1980
+ (defn float?
1981
+ "Returns true if n is a floating point number"
1982
+ [n]
1983
+ (or (instance? Double n)
1984
+ (instance? Float n)))
1985
+
1986
+ (defn rational? [n]
1987
+ "Returns true if n is a rational number"
1988
+ (or (integer? n) (ratio? n) (decimal? n)))
1989
+
1990
+ (defn bigint
1991
+ "Coerce to BigInteger"
1992
+ {:tag BigInteger}
1993
+ [x] (cond
1994
+ (instance? BigInteger x) x
1995
+ (decimal? x) (.toBigInteger #^BigDecimal x)
1996
+ (number? x) (BigInteger/valueOf (long x))
1997
+ :else (BigInteger. x)))
1998
+
1999
+ (defn bigdec
2000
+ "Coerce to BigDecimal"
2001
+ {:tag BigDecimal}
2002
+ [x] (cond
2003
+ (decimal? x) x
2004
+ (float? x) (. BigDecimal valueOf (double x))
2005
+ (ratio? x) (/ (BigDecimal. (.numerator x)) (.denominator x))
2006
+ (instance? BigInteger x) (BigDecimal. #^BigInteger x)
2007
+ (number? x) (BigDecimal/valueOf (long x))
2008
+ :else (BigDecimal. x)))
2009
+
2010
+ (def #^{:private true} print-initialized false)
2011
+
2012
+ (defmulti print-method (fn [x writer] (type x)))
2013
+ (defmulti print-dup (fn [x writer] (class x)))
2014
+
2015
+ (defn pr-on
2016
+ {:private true}
2017
+ [x w]
2018
+ (if *print-dup*
2019
+ (print-dup x w)
2020
+ (print-method x w))
2021
+ nil)
2022
+
2023
+ (defn pr
2024
+ "Prints the object(s) to the output stream that is the current value
2025
+ of *out*. Prints the object(s), separated by spaces if there is
2026
+ more than one. By default, pr and prn print in a way that objects
2027
+ can be read by the reader"
2028
+ ([] nil)
2029
+ ([x]
2030
+ (pr-on x *out*))
2031
+ ([x & more]
2032
+ (pr x)
2033
+ (. *out* (append \space))
2034
+ (apply pr more)))
2035
+
2036
+ (defn newline
2037
+ "Writes a newline to the output stream that is the current value of
2038
+ *out*"
2039
+ []
2040
+ (. *out* (append \newline))
2041
+ nil)
2042
+
2043
+ (defn flush
2044
+ "Flushes the output stream that is the current value of
2045
+ *out*"
2046
+ []
2047
+ (. *out* (flush))
2048
+ nil)
2049
+
2050
+ (defn prn
2051
+ "Same as pr followed by (newline). Observes *flush-on-newline*"
2052
+ [& more]
2053
+ (apply pr more)
2054
+ (newline)
2055
+ (when *flush-on-newline*
2056
+ (flush)))
2057
+
2058
+ (defn print
2059
+ "Prints the object(s) to the output stream that is the current value
2060
+ of *out*. print and println produce output for human consumption."
2061
+ [& more]
2062
+ (binding [*print-readably* nil]
2063
+ (apply pr more)))
2064
+
2065
+ (defn println
2066
+ "Same as print followed by (newline)"
2067
+ [& more]
2068
+ (binding [*print-readably* nil]
2069
+ (apply prn more)))
2070
+
2071
+
2072
+ (defn read
2073
+ "Reads the next object from stream, which must be an instance of
2074
+ java.io.PushbackReader or some derivee. stream defaults to the
2075
+ current value of *in* ."
2076
+ ([]
2077
+ (read *in*))
2078
+ ([stream]
2079
+ (read stream true nil))
2080
+ ([stream eof-error? eof-value]
2081
+ (read stream eof-error? eof-value false))
2082
+ ([stream eof-error? eof-value recursive?]
2083
+ (. clojure.lang.LispReader (read stream (boolean eof-error?) eof-value recursive?))))
2084
+
2085
+ (defn read-line
2086
+ "Reads the next line from stream that is the current value of *in* ."
2087
+ []
2088
+ (if (instance? clojure.lang.LineNumberingPushbackReader *in*)
2089
+ (.readLine #^clojure.lang.LineNumberingPushbackReader *in*)
2090
+ (.readLine #^java.io.BufferedReader *in*)))
2091
+
2092
+ (defn read-string
2093
+ "Reads one object from the string s"
2094
+ [s] (clojure.lang.RT/readString s))
2095
+
2096
+ (defn subvec
2097
+ "Returns a persistent vector of the items in vector from
2098
+ start (inclusive) to end (exclusive). If end is not supplied,
2099
+ defaults to (count vector). This operation is O(1) and very fast, as
2100
+ the resulting vector shares structure with the original and no
2101
+ trimming is done."
2102
+ ([v start]
2103
+ (subvec v start (count v)))
2104
+ ([v start end]
2105
+ (. clojure.lang.RT (subvec v start end))))
2106
+
2107
+ (defmacro with-open
2108
+ "bindings => [name init ...]
2109
+
2110
+ Evaluates body in a try expression with names bound to the values
2111
+ of the inits, and a finally clause that calls (.close name) on each
2112
+ name in reverse order."
2113
+ [bindings & body]
2114
+ (assert-args with-open
2115
+ (vector? bindings) "a vector for its binding"
2116
+ (even? (count bindings)) "an even number of forms in binding vector")
2117
+ (cond
2118
+ (= (count bindings) 0) `(do ~@body)
2119
+ (symbol? (bindings 0)) `(let ~(subvec bindings 0 2)
2120
+ (try
2121
+ (with-open ~(subvec bindings 2) ~@body)
2122
+ (finally
2123
+ (. ~(bindings 0) close))))
2124
+ :else (throw (IllegalArgumentException.
2125
+ "with-open only allows Symbols in bindings"))))
2126
+
2127
+ (defmacro doto
2128
+ "Evaluates x then calls all of the methods and functions with the
2129
+ value of x supplied at the from of the given arguments. The forms
2130
+ are evaluated in order. Returns x.
2131
+
2132
+ (doto (new java.util.HashMap) (.put \"a\" 1) (.put \"b\" 2))"
2133
+ [x & forms]
2134
+ (let [gx (gensym)]
2135
+ `(let [~gx ~x]
2136
+ ~@(map (fn [f]
2137
+ (if (seq? f)
2138
+ `(~(first f) ~gx ~@(next f))
2139
+ `(~f ~gx)))
2140
+ forms)
2141
+ ~gx)))
2142
+
2143
+ (defmacro memfn
2144
+ "Expands into code that creates a fn that expects to be passed an
2145
+ object and any args and calls the named instance method on the
2146
+ object passing the args. Use when you want to treat a Java method as
2147
+ a first-class fn."
2148
+ [name & args]
2149
+ `(fn [target# ~@args]
2150
+ (. target# (~name ~@args))))
2151
+
2152
+ (defmacro time
2153
+ "Evaluates expr and prints the time it took. Returns the value of
2154
+ expr."
2155
+ [expr]
2156
+ `(let [start# (. System (nanoTime))
2157
+ ret# ~expr]
2158
+ (prn (str "Elapsed time: " (/ (double (- (. System (nanoTime)) start#)) 1000000.0) " msecs"))
2159
+ ret#))
2160
+
2161
+
2162
+
2163
+ (import '(java.lang.reflect Array))
2164
+
2165
+ (defn alength
2166
+ "Returns the length of the Java array. Works on arrays of all
2167
+ types."
2168
+ {:inline (fn [a] `(. clojure.lang.RT (alength ~a)))}
2169
+ [array] (. clojure.lang.RT (alength array)))
2170
+
2171
+ (defn aclone
2172
+ "Returns a clone of the Java array. Works on arrays of known
2173
+ types."
2174
+ {:inline (fn [a] `(. clojure.lang.RT (aclone ~a)))}
2175
+ [array] (. clojure.lang.RT (aclone array)))
2176
+
2177
+ (defn aget
2178
+ "Returns the value at the index/indices. Works on Java arrays of all
2179
+ types."
2180
+ {:inline (fn [a i] `(. clojure.lang.RT (aget ~a ~i)))
2181
+ :inline-arities #{2}}
2182
+ ([array idx]
2183
+ (clojure.lang.Reflector/prepRet (. Array (get array idx))))
2184
+ ([array idx & idxs]
2185
+ (apply aget (aget array idx) idxs)))
2186
+
2187
+ (defn aset
2188
+ "Sets the value at the index/indices. Works on Java arrays of
2189
+ reference types. Returns val."
2190
+ {:inline (fn [a i v] `(. clojure.lang.RT (aset ~a ~i ~v)))
2191
+ :inline-arities #{3}}
2192
+ ([array idx val]
2193
+ (. Array (set array idx val))
2194
+ val)
2195
+ ([array idx idx2 & idxv]
2196
+ (apply aset (aget array idx) idx2 idxv)))
2197
+
2198
+ (defmacro
2199
+ #^{:private true}
2200
+ def-aset [name method coerce]
2201
+ `(defn ~name
2202
+ {:arglists '([~'array ~'idx ~'val] [~'array ~'idx ~'idx2 & ~'idxv])}
2203
+ ([array# idx# val#]
2204
+ (. Array (~method array# idx# (~coerce val#)))
2205
+ val#)
2206
+ ([array# idx# idx2# & idxv#]
2207
+ (apply ~name (aget array# idx#) idx2# idxv#))))
2208
+
2209
+ (def-aset
2210
+ #^{:doc "Sets the value at the index/indices. Works on arrays of int. Returns val."}
2211
+ aset-int setInt int)
2212
+
2213
+ (def-aset
2214
+ #^{:doc "Sets the value at the index/indices. Works on arrays of long. Returns val."}
2215
+ aset-long setLong long)
2216
+
2217
+ (def-aset
2218
+ #^{:doc "Sets the value at the index/indices. Works on arrays of boolean. Returns val."}
2219
+ aset-boolean setBoolean boolean)
2220
+
2221
+ (def-aset
2222
+ #^{:doc "Sets the value at the index/indices. Works on arrays of float. Returns val."}
2223
+ aset-float setFloat float)
2224
+
2225
+ (def-aset
2226
+ #^{:doc "Sets the value at the index/indices. Works on arrays of double. Returns val."}
2227
+ aset-double setDouble double)
2228
+
2229
+ (def-aset
2230
+ #^{:doc "Sets the value at the index/indices. Works on arrays of short. Returns val."}
2231
+ aset-short setShort short)
2232
+
2233
+ (def-aset
2234
+ #^{:doc "Sets the value at the index/indices. Works on arrays of byte. Returns val."}
2235
+ aset-byte setByte byte)
2236
+
2237
+ (def-aset
2238
+ #^{:doc "Sets the value at the index/indices. Works on arrays of char. Returns val."}
2239
+ aset-char setChar char)
2240
+
2241
+ (defn make-array
2242
+ "Creates and returns an array of instances of the specified class of
2243
+ the specified dimension(s). Note that a class object is required.
2244
+ Class objects can be obtained by using their imported or
2245
+ fully-qualified name. Class objects for the primitive types can be
2246
+ obtained using, e.g., Integer/TYPE."
2247
+ ([#^Class type len]
2248
+ (. Array (newInstance type (int len))))
2249
+ ([#^Class type dim & more-dims]
2250
+ (let [dims (cons dim more-dims)
2251
+ #^"[I" dimarray (make-array (. Integer TYPE) (count dims))]
2252
+ (dotimes [i (alength dimarray)]
2253
+ (aset-int dimarray i (nth dims i)))
2254
+ (. Array (newInstance type dimarray)))))
2255
+
2256
+ (defn to-array-2d
2257
+ "Returns a (potentially-ragged) 2-dimensional array of Objects
2258
+ containing the contents of coll, which can be any Collection of any
2259
+ Collection."
2260
+ {:tag "[[Ljava.lang.Object;"}
2261
+ [#^java.util.Collection coll]
2262
+ (let [ret (make-array (. Class (forName "[Ljava.lang.Object;")) (. coll (size)))]
2263
+ (loop [i 0 xs (seq coll)]
2264
+ (when xs
2265
+ (aset ret i (to-array (first xs)))
2266
+ (recur (inc i) (next xs))))
2267
+ ret))
2268
+
2269
+ (defn macroexpand-1
2270
+ "If form represents a macro form, returns its expansion,
2271
+ else returns form."
2272
+ [form]
2273
+ (. clojure.lang.Compiler (macroexpand1 form)))
2274
+
2275
+ (defn macroexpand
2276
+ "Repeatedly calls macroexpand-1 on form until it no longer
2277
+ represents a macro form, then returns it. Note neither
2278
+ macroexpand-1 nor macroexpand expand macros in subforms."
2279
+ [form]
2280
+ (let [ex (macroexpand-1 form)]
2281
+ (if (identical? ex form)
2282
+ form
2283
+ (macroexpand ex))))
2284
+
2285
+ (defn create-struct
2286
+ "Returns a structure basis object."
2287
+ [& keys]
2288
+ (. clojure.lang.PersistentStructMap (createSlotMap keys)))
2289
+
2290
+ (defmacro defstruct
2291
+ "Same as (def name (create-struct keys...))"
2292
+ [name & keys]
2293
+ `(def ~name (create-struct ~@keys)))
2294
+
2295
+ (defn struct-map
2296
+ "Returns a new structmap instance with the keys of the
2297
+ structure-basis. keyvals may contain all, some or none of the basis
2298
+ keys - where values are not supplied they will default to nil.
2299
+ keyvals can also contain keys not in the basis."
2300
+ [s & inits]
2301
+ (. clojure.lang.PersistentStructMap (create s inits)))
2302
+
2303
+ (defn struct
2304
+ "Returns a new structmap instance with the keys of the
2305
+ structure-basis. vals must be supplied for basis keys in order -
2306
+ where values are not supplied they will default to nil."
2307
+ [s & vals]
2308
+ (. clojure.lang.PersistentStructMap (construct s vals)))
2309
+
2310
+ (defn accessor
2311
+ "Returns a fn that, given an instance of a structmap with the basis,
2312
+ returns the value at the key. The key must be in the basis. The
2313
+ returned function should be (slightly) more efficient than using
2314
+ get, but such use of accessors should be limited to known
2315
+ performance-critical areas."
2316
+ [s key]
2317
+ (. clojure.lang.PersistentStructMap (getAccessor s key)))
2318
+
2319
+ (defn load-reader
2320
+ "Sequentially read and evaluate the set of forms contained in the
2321
+ stream/file"
2322
+ [rdr] (. clojure.lang.Compiler (load rdr)))
2323
+
2324
+ (defn load-string
2325
+ "Sequentially read and evaluate the set of forms contained in the
2326
+ string"
2327
+ [s]
2328
+ (let [rdr (-> (java.io.StringReader. s)
2329
+ (clojure.lang.LineNumberingPushbackReader.))]
2330
+ (load-reader rdr)))
2331
+
2332
+ (defn set
2333
+ "Returns a set of the distinct elements of coll."
2334
+ [coll] (apply hash-set coll))
2335
+
2336
+ (defn #^{:private true}
2337
+ filter-key [keyfn pred amap]
2338
+ (loop [ret {} es (seq amap)]
2339
+ (if es
2340
+ (if (pred (keyfn (first es)))
2341
+ (recur (assoc ret (key (first es)) (val (first es))) (next es))
2342
+ (recur ret (next es)))
2343
+ ret)))
2344
+
2345
+ (defn find-ns
2346
+ "Returns the namespace named by the symbol or nil if it doesn't exist."
2347
+ [sym] (clojure.lang.Namespace/find sym))
2348
+
2349
+ (defn create-ns
2350
+ "Create a new namespace named by the symbol if one doesn't already
2351
+ exist, returns it or the already-existing namespace of the same
2352
+ name."
2353
+ [sym] (clojure.lang.Namespace/findOrCreate sym))
2354
+
2355
+ (defn remove-ns
2356
+ "Removes the namespace named by the symbol. Use with caution.
2357
+ Cannot be used to remove the clojure namespace."
2358
+ [sym] (clojure.lang.Namespace/remove sym))
2359
+
2360
+ (defn all-ns
2361
+ "Returns a sequence of all namespaces."
2362
+ [] (clojure.lang.Namespace/all))
2363
+
2364
+ (defn #^clojure.lang.Namespace the-ns
2365
+ "If passed a namespace, returns it. Else, when passed a symbol,
2366
+ returns the namespace named by it, throwing an exception if not
2367
+ found."
2368
+ [x]
2369
+ (if (instance? clojure.lang.Namespace x)
2370
+ x
2371
+ (or (find-ns x) (throw (Exception. (str "No namespace: " x " found"))))))
2372
+
2373
+ (defn ns-name
2374
+ "Returns the name of the namespace, a symbol."
2375
+ [ns]
2376
+ (.getName (the-ns ns)))
2377
+
2378
+ (defn ns-map
2379
+ "Returns a map of all the mappings for the namespace."
2380
+ [ns]
2381
+ (.getMappings (the-ns ns)))
2382
+
2383
+ (defn ns-unmap
2384
+ "Removes the mappings for the symbol from the namespace."
2385
+ [ns sym]
2386
+ (.unmap (the-ns ns) sym))
2387
+
2388
+ ;(defn export [syms]
2389
+ ; (doseq [sym syms]
2390
+ ; (.. *ns* (intern sym) (setExported true))))
2391
+
2392
+ (defn ns-publics
2393
+ "Returns a map of the public intern mappings for the namespace."
2394
+ [ns]
2395
+ (let [ns (the-ns ns)]
2396
+ (filter-key val (fn [#^clojure.lang.Var v] (and (instance? clojure.lang.Var v)
2397
+ (= ns (.ns v))
2398
+ (.isPublic v)))
2399
+ (ns-map ns))))
2400
+
2401
+ (defn ns-imports
2402
+ "Returns a map of the import mappings for the namespace."
2403
+ [ns]
2404
+ (filter-key val (partial instance? Class) (ns-map ns)))
2405
+
2406
+ (defn refer
2407
+ "refers to all public vars of ns, subject to filters.
2408
+ filters can include at most one each of:
2409
+
2410
+ :exclude list-of-symbols
2411
+ :only list-of-symbols
2412
+ :rename map-of-fromsymbol-tosymbol
2413
+
2414
+ For each public interned var in the namespace named by the symbol,
2415
+ adds a mapping from the name of the var to the var to the current
2416
+ namespace. Throws an exception if name is already mapped to
2417
+ something else in the current namespace. Filters can be used to
2418
+ select a subset, via inclusion or exclusion, or to provide a mapping
2419
+ to a symbol different from the var's name, in order to prevent
2420
+ clashes. Use :use in the ns macro in preference to calling this directly."
2421
+ [ns-sym & filters]
2422
+ (let [ns (or (find-ns ns-sym) (throw (new Exception (str "No namespace: " ns-sym))))
2423
+ fs (apply hash-map filters)
2424
+ nspublics (ns-publics ns)
2425
+ rename (or (:rename fs) {})
2426
+ exclude (set (:exclude fs))
2427
+ to-do (or (:only fs) (keys nspublics))]
2428
+ (doseq [sym to-do]
2429
+ (when-not (exclude sym)
2430
+ (let [v (nspublics sym)]
2431
+ (when-not v
2432
+ (throw (new java.lang.IllegalAccessError (str sym " is not public"))))
2433
+ (. *ns* (refer (or (rename sym) sym) v)))))))
2434
+
2435
+ (defn ns-refers
2436
+ "Returns a map of the refer mappings for the namespace."
2437
+ [ns]
2438
+ (let [ns (the-ns ns)]
2439
+ (filter-key val (fn [#^clojure.lang.Var v] (and (instance? clojure.lang.Var v)
2440
+ (not= ns (.ns v))))
2441
+ (ns-map ns))))
2442
+
2443
+ (defn ns-interns
2444
+ "Returns a map of the intern mappings for the namespace."
2445
+ [ns]
2446
+ (let [ns (the-ns ns)]
2447
+ (filter-key val (fn [#^clojure.lang.Var v] (and (instance? clojure.lang.Var v)
2448
+ (= ns (.ns v))))
2449
+ (ns-map ns))))
2450
+
2451
+ (defn alias
2452
+ "Add an alias in the current namespace to another
2453
+ namespace. Arguments are two symbols: the alias to be used, and
2454
+ the symbolic name of the target namespace. Use :as in the ns macro in preference
2455
+ to calling this directly."
2456
+ [alias namespace-sym]
2457
+ (.addAlias *ns* alias (find-ns namespace-sym)))
2458
+
2459
+ (defn ns-aliases
2460
+ "Returns a map of the aliases for the namespace."
2461
+ [ns]
2462
+ (.getAliases (the-ns ns)))
2463
+
2464
+ (defn ns-unalias
2465
+ "Removes the alias for the symbol from the namespace."
2466
+ [ns sym]
2467
+ (.removeAlias (the-ns ns) sym))
2468
+
2469
+ (defn take-nth
2470
+ "Returns a lazy seq of every nth item in coll."
2471
+ [n coll]
2472
+ (lazy-seq
2473
+ (when-let [s (seq coll)]
2474
+ (cons (first s) (take-nth n (drop n s))))))
2475
+
2476
+ (defn interleave
2477
+ "Returns a lazy seq of the first item in each coll, then the second
2478
+ etc."
2479
+ [& colls]
2480
+ (apply concat (apply map list colls)))
2481
+
2482
+ (defn var-get
2483
+ "Gets the value in the var object"
2484
+ [#^clojure.lang.Var x] (. x (get)))
2485
+
2486
+ (defn var-set
2487
+ "Sets the value in the var object to val. The var must be
2488
+ thread-locally bound."
2489
+ [#^clojure.lang.Var x val] (. x (set val)))
2490
+
2491
+ (defmacro with-local-vars
2492
+ "varbinding=> symbol init-expr
2493
+
2494
+ Executes the exprs in a context in which the symbols are bound to
2495
+ vars with per-thread bindings to the init-exprs. The symbols refer
2496
+ to the var objects themselves, and must be accessed with var-get and
2497
+ var-set"
2498
+ [name-vals-vec & body]
2499
+ (assert-args with-local-vars
2500
+ (vector? name-vals-vec) "a vector for its binding"
2501
+ (even? (count name-vals-vec)) "an even number of forms in binding vector")
2502
+ `(let [~@(interleave (take-nth 2 name-vals-vec)
2503
+ (repeat '(. clojure.lang.Var (create))))]
2504
+ (. clojure.lang.Var (pushThreadBindings (hash-map ~@name-vals-vec)))
2505
+ (try
2506
+ ~@body
2507
+ (finally (. clojure.lang.Var (popThreadBindings))))))
2508
+
2509
+ (defn ns-resolve
2510
+ "Returns the var or Class to which a symbol will be resolved in the
2511
+ namespace, else nil. Note that if the symbol is fully qualified,
2512
+ the var/Class to which it resolves need not be present in the
2513
+ namespace."
2514
+ [ns sym]
2515
+ (clojure.lang.Compiler/maybeResolveIn (the-ns ns) sym))
2516
+
2517
+ (defn resolve
2518
+ "same as (ns-resolve *ns* symbol)"
2519
+ [sym] (ns-resolve *ns* sym))
2520
+
2521
+ (defn array-map
2522
+ "Constructs an array-map."
2523
+ ([] (. clojure.lang.PersistentArrayMap EMPTY))
2524
+ ([& keyvals] (new clojure.lang.PersistentArrayMap (to-array keyvals))))
2525
+
2526
+ (defn nthnext
2527
+ "Returns the nth next of coll, (seq coll) when n is 0."
2528
+ [coll n]
2529
+ (loop [n n xs (seq coll)]
2530
+ (if (and xs (pos? n))
2531
+ (recur (dec n) (next xs))
2532
+ xs)))
2533
+
2534
+
2535
+ ;redefine let and loop with destructuring
2536
+ (defn destructure [bindings]
2537
+ (let [bmap (apply array-map bindings)
2538
+ pb (fn pb [bvec b v]
2539
+ (let [pvec
2540
+ (fn [bvec b val]
2541
+ (let [gvec (gensym "vec__")]
2542
+ (loop [ret (-> bvec (conj gvec) (conj val))
2543
+ n 0
2544
+ bs b
2545
+ seen-rest? false]
2546
+ (if (seq bs)
2547
+ (let [firstb (first bs)]
2548
+ (cond
2549
+ (= firstb '&) (recur (pb ret (second bs) (list `nthnext gvec n))
2550
+ n
2551
+ (nnext bs)
2552
+ true)
2553
+ (= firstb :as) (pb ret (second bs) gvec)
2554
+ :else (if seen-rest?
2555
+ (throw (new Exception "Unsupported binding form, only :as can follow & parameter"))
2556
+ (recur (pb ret firstb (list `nth gvec n nil))
2557
+ (inc n)
2558
+ (next bs)
2559
+ seen-rest?))))
2560
+ ret))))
2561
+ pmap
2562
+ (fn [bvec b v]
2563
+ (let [gmap (or (:as b) (gensym "map__"))
2564
+ defaults (:or b)]
2565
+ (loop [ret (-> bvec (conj gmap) (conj v))
2566
+ bes (reduce
2567
+ (fn [bes entry]
2568
+ (reduce #(assoc %1 %2 ((val entry) %2))
2569
+ (dissoc bes (key entry))
2570
+ ((key entry) bes)))
2571
+ (dissoc b :as :or)
2572
+ {:keys #(keyword (str %)), :strs str, :syms #(list `quote %)})]
2573
+ (if (seq bes)
2574
+ (let [bb (key (first bes))
2575
+ bk (val (first bes))
2576
+ has-default (contains? defaults bb)]
2577
+ (recur (pb ret bb (if has-default
2578
+ (list `get gmap bk (defaults bb))
2579
+ (list `get gmap bk)))
2580
+ (next bes)))
2581
+ ret))))]
2582
+ (cond
2583
+ (symbol? b) (-> bvec (conj b) (conj v))
2584
+ (vector? b) (pvec bvec b v)
2585
+ (map? b) (pmap bvec b v)
2586
+ :else (throw (new Exception (str "Unsupported binding form: " b))))))
2587
+ process-entry (fn [bvec b] (pb bvec (key b) (val b)))]
2588
+ (if (every? symbol? (keys bmap))
2589
+ bindings
2590
+ (reduce process-entry [] bmap))))
2591
+
2592
+ (defmacro let
2593
+ "Evaluates the exprs in a lexical context in which the symbols in
2594
+ the binding-forms are bound to their respective init-exprs or parts
2595
+ therein."
2596
+ [bindings & body]
2597
+ (assert-args let
2598
+ (vector? bindings) "a vector for its binding"
2599
+ (even? (count bindings)) "an even number of forms in binding vector")
2600
+ `(let* ~(destructure bindings) ~@body))
2601
+
2602
+ ;redefine fn with destructuring
2603
+ (defmacro fn
2604
+ "(fn name? [params* ] exprs*)
2605
+ (fn name? ([params* ] exprs*)+)
2606
+
2607
+ params => positional-params* , or positional-params* & next-param
2608
+ positional-param => binding-form
2609
+ next-param => binding-form
2610
+ name => symbol
2611
+
2612
+ Defines a function"
2613
+ [& sigs]
2614
+ (let [name (if (symbol? (first sigs)) (first sigs) nil)
2615
+ sigs (if name (next sigs) sigs)
2616
+ sigs (if (vector? (first sigs)) (list sigs) sigs)
2617
+ psig (fn [sig]
2618
+ (let [[params & body] sig]
2619
+ (if (every? symbol? params)
2620
+ sig
2621
+ (loop [params params
2622
+ new-params []
2623
+ lets []]
2624
+ (if params
2625
+ (if (symbol? (first params))
2626
+ (recur (next params) (conj new-params (first params)) lets)
2627
+ (let [gparam (gensym "p__")]
2628
+ (recur (next params) (conj new-params gparam)
2629
+ (-> lets (conj (first params)) (conj gparam)))))
2630
+ `(~new-params
2631
+ (let ~lets
2632
+ ~@body)))))))
2633
+ new-sigs (map psig sigs)]
2634
+ (with-meta
2635
+ (if name
2636
+ (list* 'fn* name new-sigs)
2637
+ (cons 'fn* new-sigs))
2638
+ *macro-meta*)))
2639
+
2640
+ (defmacro loop
2641
+ "Evaluates the exprs in a lexical context in which the symbols in
2642
+ the binding-forms are bound to their respective init-exprs or parts
2643
+ therein. Acts as a recur target."
2644
+ [bindings & body]
2645
+ (assert-args loop
2646
+ (vector? bindings) "a vector for its binding"
2647
+ (even? (count bindings)) "an even number of forms in binding vector")
2648
+ (let [db (destructure bindings)]
2649
+ (if (= db bindings)
2650
+ `(loop* ~bindings ~@body)
2651
+ (let [vs (take-nth 2 (drop 1 bindings))
2652
+ bs (take-nth 2 bindings)
2653
+ gs (map (fn [b] (if (symbol? b) b (gensym))) bs)
2654
+ bfs (reduce (fn [ret [b v g]]
2655
+ (if (symbol? b)
2656
+ (conj ret g v)
2657
+ (conj ret g v b g)))
2658
+ [] (map vector bs vs gs))]
2659
+ `(let ~bfs
2660
+ (loop* ~(vec (interleave gs gs))
2661
+ (let ~(vec (interleave bs gs))
2662
+ ~@body)))))))
2663
+
2664
+ (defmacro when-first
2665
+ "bindings => x xs
2666
+
2667
+ Same as (when (seq xs) (let [x (first xs)] body))"
2668
+ [bindings & body]
2669
+ (assert-args when-first
2670
+ (vector? bindings) "a vector for its binding"
2671
+ (= 2 (count bindings)) "exactly 2 forms in binding vector")
2672
+ (let [[x xs] bindings]
2673
+ `(when (seq ~xs)
2674
+ (let [~x (first ~xs)]
2675
+ ~@body))))
2676
+
2677
+ (defmacro lazy-cat
2678
+ "Expands to code which yields a lazy sequence of the concatenation
2679
+ of the supplied colls. Each coll expr is not evaluated until it is
2680
+ needed.
2681
+
2682
+ (lazy-cat xs ys zs) === (concat (lazy-seq xs) (lazy-seq ys) (lazy-seq zs))"
2683
+ [& colls]
2684
+ `(concat ~@(map #(list `lazy-seq %) colls)))
2685
+
2686
+ (defmacro for
2687
+ "List comprehension. Takes a vector of one or more
2688
+ binding-form/collection-expr pairs, each followed by zero or more
2689
+ modifiers, and yields a lazy sequence of evaluations of expr.
2690
+ Collections are iterated in a nested fashion, rightmost fastest,
2691
+ and nested coll-exprs can refer to bindings created in prior
2692
+ binding-forms. Supported modifiers are: :let [binding-form expr ...],
2693
+ :while test, :when test.
2694
+
2695
+ (take 100 (for [x (range 100000000) y (range 1000000) :while (< y x)] [x y]))"
2696
+ [seq-exprs body-expr]
2697
+ (assert-args for
2698
+ (vector? seq-exprs) "a vector for its binding"
2699
+ (even? (count seq-exprs)) "an even number of forms in binding vector")
2700
+ (let [to-groups (fn [seq-exprs]
2701
+ (reduce (fn [groups [k v]]
2702
+ (if (keyword? k)
2703
+ (conj (pop groups) (conj (peek groups) [k v]))
2704
+ (conj groups [k v])))
2705
+ [] (partition 2 seq-exprs)))
2706
+ err (fn [& msg] (throw (IllegalArgumentException. (apply str msg))))
2707
+ emit-bind (fn emit-bind [[[bind expr & mod-pairs]
2708
+ & [[_ next-expr] :as next-groups]]]
2709
+ (let [giter (gensym "iter__")
2710
+ gxs (gensym "s__")
2711
+ do-mod (fn do-mod [[[k v :as pair] & etc]]
2712
+ (cond
2713
+ (= k :let) `(let ~v ~(do-mod etc))
2714
+ (= k :while) `(when ~v ~(do-mod etc))
2715
+ (= k :when) `(if ~v
2716
+ ~(do-mod etc)
2717
+ (recur (rest ~gxs)))
2718
+ (keyword? k) (err "Invalid 'for' keyword " k)
2719
+ next-groups
2720
+ `(let [iterys# ~(emit-bind next-groups)
2721
+ fs# (seq (iterys# ~next-expr))]
2722
+ (if fs#
2723
+ (concat fs# (~giter (rest ~gxs)))
2724
+ (recur (rest ~gxs))))
2725
+ :else `(cons ~body-expr
2726
+ (~giter (rest ~gxs)))))]
2727
+ `(fn ~giter [~gxs]
2728
+ (lazy-seq
2729
+ (loop [~gxs ~gxs]
2730
+ (when-first [~bind ~gxs]
2731
+ ~(do-mod mod-pairs)))))))]
2732
+ `(let [iter# ~(emit-bind (to-groups seq-exprs))]
2733
+ (iter# ~(second seq-exprs)))))
2734
+
2735
+ (defmacro comment
2736
+ "Ignores body, yields nil"
2737
+ [& body])
2738
+
2739
+ (defmacro with-out-str
2740
+ "Evaluates exprs in a context in which *out* is bound to a fresh
2741
+ StringWriter. Returns the string created by any nested printing
2742
+ calls."
2743
+ [& body]
2744
+ `(let [s# (new java.io.StringWriter)]
2745
+ (binding [*out* s#]
2746
+ ~@body
2747
+ (str s#))))
2748
+
2749
+ (defmacro with-in-str
2750
+ "Evaluates body in a context in which *in* is bound to a fresh
2751
+ StringReader initialized with the string s."
2752
+ [s & body]
2753
+ `(with-open [s# (-> (java.io.StringReader. ~s) clojure.lang.LineNumberingPushbackReader.)]
2754
+ (binding [*in* s#]
2755
+ ~@body)))
2756
+
2757
+ (defn pr-str
2758
+ "pr to a string, returning it"
2759
+ {:tag String}
2760
+ [& xs]
2761
+ (with-out-str
2762
+ (apply pr xs)))
2763
+
2764
+ (defn prn-str
2765
+ "prn to a string, returning it"
2766
+ {:tag String}
2767
+ [& xs]
2768
+ (with-out-str
2769
+ (apply prn xs)))
2770
+
2771
+ (defn print-str
2772
+ "print to a string, returning it"
2773
+ {:tag String}
2774
+ [& xs]
2775
+ (with-out-str
2776
+ (apply print xs)))
2777
+
2778
+ (defn println-str
2779
+ "println to a string, returning it"
2780
+ {:tag String}
2781
+ [& xs]
2782
+ (with-out-str
2783
+ (apply println xs)))
2784
+
2785
+ (defmacro assert
2786
+ "Evaluates expr and throws an exception if it does not evaluate to
2787
+ logical true."
2788
+ [x]
2789
+ `(when-not ~x
2790
+ (throw (new Exception (str "Assert failed: " (pr-str '~x))))))
2791
+
2792
+ (defn test
2793
+ "test [v] finds fn at key :test in var metadata and calls it,
2794
+ presuming failure will throw exception"
2795
+ [v]
2796
+ (let [f (:test ^v)]
2797
+ (if f
2798
+ (do (f) :ok)
2799
+ :no-test)))
2800
+
2801
+ (defn re-pattern
2802
+ "Returns an instance of java.util.regex.Pattern, for use, e.g. in
2803
+ re-matcher."
2804
+ {:tag java.util.regex.Pattern}
2805
+ [s] (if (instance? java.util.regex.Pattern s)
2806
+ s
2807
+ (. java.util.regex.Pattern (compile s))))
2808
+
2809
+ (defn re-matcher
2810
+ "Returns an instance of java.util.regex.Matcher, for use, e.g. in
2811
+ re-find."
2812
+ {:tag java.util.regex.Matcher}
2813
+ [#^java.util.regex.Pattern re s]
2814
+ (. re (matcher s)))
2815
+
2816
+ (defn re-groups
2817
+ "Returns the groups from the most recent match/find. If there are no
2818
+ nested groups, returns a string of the entire match. If there are
2819
+ nested groups, returns a vector of the groups, the first element
2820
+ being the entire match."
2821
+ [#^java.util.regex.Matcher m]
2822
+ (let [gc (. m (groupCount))]
2823
+ (if (zero? gc)
2824
+ (. m (group))
2825
+ (loop [ret [] c 0]
2826
+ (if (<= c gc)
2827
+ (recur (conj ret (. m (group c))) (inc c))
2828
+ ret)))))
2829
+
2830
+ (defn re-seq
2831
+ "Returns a lazy sequence of successive matches of pattern in string,
2832
+ using java.util.regex.Matcher.find(), each such match processed with
2833
+ re-groups."
2834
+ [#^java.util.regex.Pattern re s]
2835
+ (let [m (re-matcher re s)]
2836
+ ((fn step []
2837
+ (lazy-seq
2838
+ (when (. m (find))
2839
+ (cons (re-groups m) (step))))))))
2840
+
2841
+ (defn re-matches
2842
+ "Returns the match, if any, of string to pattern, using
2843
+ java.util.regex.Matcher.matches(). Uses re-groups to return the
2844
+ groups."
2845
+ [#^java.util.regex.Pattern re s]
2846
+ (let [m (re-matcher re s)]
2847
+ (when (. m (matches))
2848
+ (re-groups m))))
2849
+
2850
+
2851
+ (defn re-find
2852
+ "Returns the next regex match, if any, of string to pattern, using
2853
+ java.util.regex.Matcher.find(). Uses re-groups to return the
2854
+ groups."
2855
+ ([#^java.util.regex.Matcher m]
2856
+ (when (. m (find))
2857
+ (re-groups m)))
2858
+ ([#^java.util.regex.Pattern re s]
2859
+ (let [m (re-matcher re s)]
2860
+ (re-find m))))
2861
+
2862
+ (defn rand
2863
+ "Returns a random floating point number between 0 (inclusive) and
2864
+ n (default 1) (exclusive)."
2865
+ ([] (. Math (random)))
2866
+ ([n] (* n (rand))))
2867
+
2868
+ (defn rand-int
2869
+ "Returns a random integer between 0 (inclusive) and n (exclusive)."
2870
+ [n] (int (rand n)))
2871
+
2872
+ (defmacro defn-
2873
+ "same as defn, yielding non-public def"
2874
+ [name & decls]
2875
+ (list* `defn (with-meta name (assoc (meta name) :private true)) decls))
2876
+
2877
+ (defn print-doc [v]
2878
+ (println "-------------------------")
2879
+ (println (str (ns-name (:ns ^v)) "/" (:name ^v)))
2880
+ (prn (:arglists ^v))
2881
+ (when (:macro ^v)
2882
+ (println "Macro"))
2883
+ (println " " (:doc ^v)))
2884
+
2885
+ (defn find-doc
2886
+ "Prints documentation for any var whose documentation or name
2887
+ contains a match for re-string-or-pattern"
2888
+ [re-string-or-pattern]
2889
+ (let [re (re-pattern re-string-or-pattern)]
2890
+ (doseq [ns (all-ns)
2891
+ v (sort-by (comp :name meta) (vals (ns-interns ns)))
2892
+ :when (and (:doc ^v)
2893
+ (or (re-find (re-matcher re (:doc ^v)))
2894
+ (re-find (re-matcher re (str (:name ^v))))))]
2895
+ (print-doc v))))
2896
+
2897
+ (defn special-form-anchor
2898
+ "Returns the anchor tag on http://clojure.org/special_forms for the
2899
+ special form x, or nil"
2900
+ [x]
2901
+ (#{'. 'def 'do 'fn 'if 'let 'loop 'monitor-enter 'monitor-exit 'new
2902
+ 'quote 'recur 'set! 'throw 'try 'var} x))
2903
+
2904
+ (defn syntax-symbol-anchor
2905
+ "Returns the anchor tag on http://clojure.org/special_forms for the
2906
+ special form that uses syntax symbol x, or nil"
2907
+ [x]
2908
+ ({'& 'fn 'catch 'try 'finally 'try} x))
2909
+
2910
+ (defn print-special-doc
2911
+ [name type anchor]
2912
+ (println "-------------------------")
2913
+ (println name)
2914
+ (println type)
2915
+ (println (str " Please see http://clojure.org/special_forms#" anchor)))
2916
+
2917
+ (defn print-namespace-doc
2918
+ "Print the documentation string of a Namespace."
2919
+ [nspace]
2920
+ (println "-------------------------")
2921
+ (println (str (ns-name nspace)))
2922
+ (println " " (:doc ^nspace)))
2923
+
2924
+ (defmacro doc
2925
+ "Prints documentation for a var or special form given its name"
2926
+ [name]
2927
+ (cond
2928
+ (special-form-anchor `~name)
2929
+ `(print-special-doc '~name "Special Form" (special-form-anchor '~name))
2930
+ (syntax-symbol-anchor `~name)
2931
+ `(print-special-doc '~name "Syntax Symbol" (syntax-symbol-anchor '~name))
2932
+ :else
2933
+ (let [nspace (find-ns name)]
2934
+ (if nspace
2935
+ `(print-namespace-doc ~nspace)
2936
+ `(print-doc (var ~name))))))
2937
+
2938
+ (defn tree-seq
2939
+ "Returns a lazy sequence of the nodes in a tree, via a depth-first walk.
2940
+ branch? must be a fn of one arg that returns true if passed a node
2941
+ that can have children (but may not). children must be a fn of one
2942
+ arg that returns a sequence of the children. Will only be called on
2943
+ nodes for which branch? returns true. Root is the root node of the
2944
+ tree."
2945
+ [branch? children root]
2946
+ (let [walk (fn walk [node]
2947
+ (lazy-seq
2948
+ (cons node
2949
+ (when (branch? node)
2950
+ (mapcat walk (children node))))))]
2951
+ (walk root)))
2952
+
2953
+ (defn file-seq
2954
+ "A tree seq on java.io.Files"
2955
+ [dir]
2956
+ (tree-seq
2957
+ (fn [#^java.io.File f] (. f (isDirectory)))
2958
+ (fn [#^java.io.File d] (seq (. d (listFiles))))
2959
+ dir))
2960
+
2961
+ (defn xml-seq
2962
+ "A tree seq on the xml elements as per xml/parse"
2963
+ [root]
2964
+ (tree-seq
2965
+ (complement string?)
2966
+ (comp seq :content)
2967
+ root))
2968
+
2969
+ (defn special-symbol?
2970
+ "Returns true if s names a special form"
2971
+ [s]
2972
+ (contains? (. clojure.lang.Compiler specials) s))
2973
+
2974
+ (defn var?
2975
+ "Returns true if v is of type clojure.lang.Var"
2976
+ [v] (instance? clojure.lang.Var v))
2977
+
2978
+ (defn slurp
2979
+ "Reads the file named by f into a string and returns it."
2980
+ [#^String f]
2981
+ (with-open [r (new java.io.BufferedReader (new java.io.FileReader f))]
2982
+ (let [sb (new StringBuilder)]
2983
+ (loop [c (. r (read))]
2984
+ (if (neg? c)
2985
+ (str sb)
2986
+ (do
2987
+ (. sb (append (char c)))
2988
+ (recur (. r (read)))))))))
2989
+
2990
+ (defn subs
2991
+ "Returns the substring of s beginning at start inclusive, and ending
2992
+ at end (defaults to length of string), exclusive."
2993
+ ([#^String s start] (. s (substring start)))
2994
+ ([#^String s start end] (. s (substring start end))))
2995
+
2996
+ (defn max-key
2997
+ "Returns the x for which (k x), a number, is greatest."
2998
+ ([k x] x)
2999
+ ([k x y] (if (> (k x) (k y)) x y))
3000
+ ([k x y & more]
3001
+ (reduce #(max-key k %1 %2) (max-key k x y) more)))
3002
+
3003
+ (defn min-key
3004
+ "Returns the x for which (k x), a number, is least."
3005
+ ([k x] x)
3006
+ ([k x y] (if (< (k x) (k y)) x y))
3007
+ ([k x y & more]
3008
+ (reduce #(min-key k %1 %2) (min-key k x y) more)))
3009
+
3010
+ (defn distinct
3011
+ "Returns a lazy sequence of the elements of coll with duplicates removed"
3012
+ [coll]
3013
+ (let [step (fn step [xs seen]
3014
+ (lazy-seq
3015
+ ((fn [[f :as xs] seen]
3016
+ (when-let [s (seq xs)]
3017
+ (if (contains? seen f)
3018
+ (recur (rest s) seen)
3019
+ (cons f (step (rest s) (conj seen f))))))
3020
+ xs seen)))]
3021
+ (step coll #{})))
3022
+
3023
+
3024
+
3025
+ (defn replace
3026
+ "Given a map of replacement pairs and a vector/collection, returns a
3027
+ vector/seq with any elements = a key in smap replaced with the
3028
+ corresponding val in smap"
3029
+ [smap coll]
3030
+ (if (vector? coll)
3031
+ (reduce (fn [v i]
3032
+ (if-let [e (find smap (nth v i))]
3033
+ (assoc v i (val e))
3034
+ v))
3035
+ coll (range (count coll)))
3036
+ (map #(if-let [e (find smap %)] (val e) %) coll)))
3037
+
3038
+ (defmacro dosync
3039
+ "Runs the exprs (in an implicit do) in a transaction that encompasses
3040
+ exprs and any nested calls. Starts a transaction if none is already
3041
+ running on this thread. Any uncaught exception will abort the
3042
+ transaction and flow out of dosync. The exprs may be run more than
3043
+ once, but any effects on Refs will be atomic."
3044
+ [& exprs]
3045
+ `(sync nil ~@exprs))
3046
+
3047
+ (defmacro with-precision
3048
+ "Sets the precision and rounding mode to be used for BigDecimal operations.
3049
+
3050
+ Usage: (with-precision 10 (/ 1M 3))
3051
+ or: (with-precision 10 :rounding HALF_DOWN (/ 1M 3))
3052
+
3053
+ The rounding mode is one of CEILING, FLOOR, HALF_UP, HALF_DOWN,
3054
+ HALF_EVEN, UP, DOWN and UNNECESSARY; it defaults to HALF_UP."
3055
+ [precision & exprs]
3056
+ (let [[body rm] (if (= (first exprs) :rounding)
3057
+ [(next (next exprs))
3058
+ `((. java.math.RoundingMode ~(second exprs)))]
3059
+ [exprs nil])]
3060
+ `(binding [*math-context* (java.math.MathContext. ~precision ~@rm)]
3061
+ ~@body)))
3062
+
3063
+ (defn bound-fn
3064
+ {:private true}
3065
+ [#^clojure.lang.Sorted sc test key]
3066
+ (fn [e]
3067
+ (test (.. sc comparator (compare (. sc entryKey e) key)) 0)))
3068
+
3069
+ (defn subseq
3070
+ "sc must be a sorted collection, test(s) one of <, <=, > or
3071
+ >=. Returns a seq of those entries with keys ek for
3072
+ which (test (.. sc comparator (compare ek key)) 0) is true"
3073
+ ([#^clojure.lang.Sorted sc test key]
3074
+ (let [include (bound-fn sc test key)]
3075
+ (if (#{> >=} test)
3076
+ (when-let [[e :as s] (. sc seqFrom key true)]
3077
+ (if (include e) s (next s)))
3078
+ (take-while include (. sc seq true)))))
3079
+ ([#^clojure.lang.Sorted sc start-test start-key end-test end-key]
3080
+ (when-let [[e :as s] (. sc seqFrom start-key true)]
3081
+ (take-while (bound-fn sc end-test end-key)
3082
+ (if ((bound-fn sc start-test start-key) e) s (next s))))))
3083
+
3084
+ (defn rsubseq
3085
+ "sc must be a sorted collection, test(s) one of <, <=, > or
3086
+ >=. Returns a reverse seq of those entries with keys ek for
3087
+ which (test (.. sc comparator (compare ek key)) 0) is true"
3088
+ ([#^clojure.lang.Sorted sc test key]
3089
+ (let [include (bound-fn sc test key)]
3090
+ (if (#{< <=} test)
3091
+ (when-let [[e :as s] (. sc seqFrom key false)]
3092
+ (if (include e) s (next s)))
3093
+ (take-while include (. sc seq false)))))
3094
+ ([#^clojure.lang.Sorted sc start-test start-key end-test end-key]
3095
+ (when-let [[e :as s] (. sc seqFrom end-key false)]
3096
+ (take-while (bound-fn sc start-test start-key)
3097
+ (if ((bound-fn sc end-test end-key) e) s (next s))))))
3098
+
3099
+ (defn repeatedly
3100
+ "Takes a function of no args, presumably with side effects, and returns an infinite
3101
+ lazy sequence of calls to it"
3102
+ [f] (lazy-seq (cons (f) (repeatedly f))))
3103
+
3104
+ (defn add-classpath
3105
+ "Adds the url (String or URL object) to the classpath per URLClassLoader.addURL"
3106
+ [url] (. clojure.lang.RT addURL url))
3107
+
3108
+
3109
+
3110
+ (defn hash
3111
+ "Returns the hash code of its argument"
3112
+ [x] (. clojure.lang.Util (hash x)))
3113
+
3114
+ (defn interpose
3115
+ "Returns a lazy seq of the elements of coll separated by sep"
3116
+ [sep coll] (drop 1 (interleave (repeat sep) coll)))
3117
+
3118
+ (defmacro definline
3119
+ "Experimental - like defmacro, except defines a named function whose
3120
+ body is the expansion, calls to which may be expanded inline as if
3121
+ it were a macro. Cannot be used with variadic (&) args."
3122
+ [name & decl]
3123
+ (let [[pre-args [args expr]] (split-with (comp not vector?) decl)]
3124
+ `(do
3125
+ (defn ~name ~@pre-args ~args ~(apply (eval (list `fn args expr)) args))
3126
+ (alter-meta! (var ~name) assoc :inline (fn ~args ~expr))
3127
+ (var ~name))))
3128
+
3129
+ (defn empty
3130
+ "Returns an empty collection of the same category as coll, or nil"
3131
+ [coll]
3132
+ (when (instance? clojure.lang.IPersistentCollection coll)
3133
+ (.empty #^clojure.lang.IPersistentCollection coll)))
3134
+
3135
+ (defmacro amap
3136
+ "Maps an expression across an array a, using an index named idx, and
3137
+ return value named ret, initialized to a clone of a, then setting each element of
3138
+ ret to the evaluation of expr, returning the new array ret."
3139
+ [a idx ret expr]
3140
+ `(let [a# ~a
3141
+ ~ret (aclone a#)]
3142
+ (loop [~idx (int 0)]
3143
+ (if (< ~idx (alength a#))
3144
+ (do
3145
+ (aset ~ret ~idx ~expr)
3146
+ (recur (unchecked-inc ~idx)))
3147
+ ~ret))))
3148
+
3149
+ (defmacro areduce
3150
+ "Reduces an expression across an array a, using an index named idx,
3151
+ and return value named ret, initialized to init, setting ret to the evaluation of expr at
3152
+ each step, returning ret."
3153
+ [a idx ret init expr]
3154
+ `(let [a# ~a]
3155
+ (loop [~idx (int 0) ~ret ~init]
3156
+ (if (< ~idx (alength a#))
3157
+ (recur (unchecked-inc ~idx) ~expr)
3158
+ ~ret))))
3159
+
3160
+ (defn float-array
3161
+ "Creates an array of floats"
3162
+ {:inline (fn [& args] `(. clojure.lang.Numbers float_array ~@args))
3163
+ :inline-arities #{1 2}}
3164
+ ([size-or-seq] (. clojure.lang.Numbers float_array size-or-seq))
3165
+ ([size init-val-or-seq] (. clojure.lang.Numbers float_array size init-val-or-seq)))
3166
+
3167
+ (defn double-array
3168
+ "Creates an array of doubles"
3169
+ {:inline (fn [& args] `(. clojure.lang.Numbers double_array ~@args))
3170
+ :inline-arities #{1 2}}
3171
+ ([size-or-seq] (. clojure.lang.Numbers double_array size-or-seq))
3172
+ ([size init-val-or-seq] (. clojure.lang.Numbers double_array size init-val-or-seq)))
3173
+
3174
+ (defn int-array
3175
+ "Creates an array of ints"
3176
+ {:inline (fn [& args] `(. clojure.lang.Numbers int_array ~@args))
3177
+ :inline-arities #{1 2}}
3178
+ ([size-or-seq] (. clojure.lang.Numbers int_array size-or-seq))
3179
+ ([size init-val-or-seq] (. clojure.lang.Numbers int_array size init-val-or-seq)))
3180
+
3181
+ (defn long-array
3182
+ "Creates an array of ints"
3183
+ {:inline (fn [& args] `(. clojure.lang.Numbers long_array ~@args))
3184
+ :inline-arities #{1 2}}
3185
+ ([size-or-seq] (. clojure.lang.Numbers long_array size-or-seq))
3186
+ ([size init-val-or-seq] (. clojure.lang.Numbers long_array size init-val-or-seq)))
3187
+
3188
+ (definline floats
3189
+ "Casts to float[]"
3190
+ [xs] `(. clojure.lang.Numbers floats ~xs))
3191
+
3192
+ (definline ints
3193
+ "Casts to int[]"
3194
+ [xs] `(. clojure.lang.Numbers ints ~xs))
3195
+
3196
+ (definline doubles
3197
+ "Casts to double[]"
3198
+ [xs] `(. clojure.lang.Numbers doubles ~xs))
3199
+
3200
+ (definline longs
3201
+ "Casts to long[]"
3202
+ [xs] `(. clojure.lang.Numbers longs ~xs))
3203
+
3204
+ (import '(java.util.concurrent BlockingQueue LinkedBlockingQueue))
3205
+
3206
+ (defn seque
3207
+ "Creates a queued seq on another (presumably lazy) seq s. The queued
3208
+ seq will produce a concrete seq in the background, and can get up to
3209
+ n items ahead of the consumer. n-or-q can be an integer n buffer
3210
+ size, or an instance of java.util.concurrent BlockingQueue. Note
3211
+ that reading from a seque can block if the reader gets ahead of the
3212
+ producer."
3213
+ ([s] (seque 100 s))
3214
+ ([n-or-q s]
3215
+ (let [#^BlockingQueue q (if (instance? BlockingQueue n-or-q)
3216
+ n-or-q
3217
+ (LinkedBlockingQueue. (int n-or-q)))
3218
+ NIL (Object.) ;nil sentinel since LBQ doesn't support nils
3219
+ agt (agent (seq s))
3220
+ fill (fn [s]
3221
+ (try
3222
+ (loop [[x & xs :as s] s]
3223
+ (if s
3224
+ (if (.offer q (if (nil? x) NIL x))
3225
+ (recur xs)
3226
+ s)
3227
+ (.put q q))) ; q itself is eos sentinel
3228
+ (catch Exception e
3229
+ (.put q q)
3230
+ (throw e))))
3231
+ drain (fn drain []
3232
+ (lazy-seq
3233
+ (let [x (.take q)]
3234
+ (if (identical? x q) ;q itself is eos sentinel
3235
+ (do @agt nil) ;touch agent just to propagate errors
3236
+ (do
3237
+ (send-off agt fill)
3238
+ (cons (if (identical? x NIL) nil x) (drain)))))))]
3239
+ (send-off agt fill)
3240
+ (drain))))
3241
+
3242
+ (defn class?
3243
+ "Returns true if x is an instance of Class"
3244
+ [x] (instance? Class x))
3245
+
3246
+ (defn alter-var-root
3247
+ "Atomically alters the root binding of var v by applying f to its
3248
+ current value plus any args"
3249
+ [#^clojure.lang.Var v f & args] (.alterRoot v f args))
3250
+
3251
+ (defn make-hierarchy
3252
+ "Creates a hierarchy object for use with derive, isa? etc."
3253
+ [] {:parents {} :descendants {} :ancestors {}})
3254
+
3255
+ (def #^{:private true}
3256
+ global-hierarchy (make-hierarchy))
3257
+
3258
+ (defn not-empty
3259
+ "If coll is empty, returns nil, else coll"
3260
+ [coll] (when (seq coll) coll))
3261
+
3262
+ (defn bases
3263
+ "Returns the immediate superclass and direct interfaces of c, if any"
3264
+ [#^Class c]
3265
+ (let [i (.getInterfaces c)
3266
+ s (.getSuperclass c)]
3267
+ (not-empty
3268
+ (if s (cons s i) i))))
3269
+
3270
+ (defn supers
3271
+ "Returns the immediate and indirect superclasses and interfaces of c, if any"
3272
+ [#^Class class]
3273
+ (loop [ret (set (bases class)) cs ret]
3274
+ (if (seq cs)
3275
+ (let [c (first cs) bs (bases c)]
3276
+ (recur (into ret bs) (into (disj cs c) bs)))
3277
+ (not-empty ret))))
3278
+
3279
+ (defn isa?
3280
+ "Returns true if (= child parent), or child is directly or indirectly derived from
3281
+ parent, either via a Java type inheritance relationship or a
3282
+ relationship established via derive. h must be a hierarchy obtained
3283
+ from make-hierarchy, if not supplied defaults to the global
3284
+ hierarchy"
3285
+ ([child parent] (isa? global-hierarchy child parent))
3286
+ ([h child parent]
3287
+ (or (= child parent)
3288
+ (and (class? parent) (class? child)
3289
+ (. #^Class parent isAssignableFrom child))
3290
+ (contains? ((:ancestors h) child) parent)
3291
+ (and (class? child) (some #(contains? ((:ancestors h) %) parent) (supers child)))
3292
+ (and (vector? parent) (vector? child)
3293
+ (= (count parent) (count child))
3294
+ (loop [ret true i 0]
3295
+ (if (or (not ret) (= i (count parent)))
3296
+ ret
3297
+ (recur (isa? h (child i) (parent i)) (inc i))))))))
3298
+
3299
+ (defn parents
3300
+ "Returns the immediate parents of tag, either via a Java type
3301
+ inheritance relationship or a relationship established via derive. h
3302
+ must be a hierarchy obtained from make-hierarchy, if not supplied
3303
+ defaults to the global hierarchy"
3304
+ ([tag] (parents global-hierarchy tag))
3305
+ ([h tag] (not-empty
3306
+ (let [tp (get (:parents h) tag)]
3307
+ (if (class? tag)
3308
+ (into (set (bases tag)) tp)
3309
+ tp)))))
3310
+
3311
+ (defn ancestors
3312
+ "Returns the immediate and indirect parents of tag, either via a Java type
3313
+ inheritance relationship or a relationship established via derive. h
3314
+ must be a hierarchy obtained from make-hierarchy, if not supplied
3315
+ defaults to the global hierarchy"
3316
+ ([tag] (ancestors global-hierarchy tag))
3317
+ ([h tag] (not-empty
3318
+ (let [ta (get (:ancestors h) tag)]
3319
+ (if (class? tag)
3320
+ (let [superclasses (set (supers tag))]
3321
+ (reduce into superclasses
3322
+ (cons ta
3323
+ (map #(get (:ancestors h) %) superclasses))))
3324
+ ta)))))
3325
+
3326
+ (defn descendants
3327
+ "Returns the immediate and indirect children of tag, through a
3328
+ relationship established via derive. h must be a hierarchy obtained
3329
+ from make-hierarchy, if not supplied defaults to the global
3330
+ hierarchy. Note: does not work on Java type inheritance
3331
+ relationships."
3332
+ ([tag] (descendants global-hierarchy tag))
3333
+ ([h tag] (if (class? tag)
3334
+ (throw (java.lang.UnsupportedOperationException. "Can't get descendants of classes"))
3335
+ (not-empty (get (:descendants h) tag)))))
3336
+
3337
+ (defn derive
3338
+ "Establishes a parent/child relationship between parent and
3339
+ tag. Parent must be a namespace-qualified symbol or keyword and
3340
+ child can be either a namespace-qualified symbol or keyword or a
3341
+ class. h must be a hierarchy obtained from make-hierarchy, if not
3342
+ supplied defaults to, and modifies, the global hierarchy."
3343
+ ([tag parent]
3344
+ (assert (namespace parent))
3345
+ (assert (or (class? tag) (and (instance? clojure.lang.Named tag) (namespace tag))))
3346
+
3347
+ (alter-var-root #'global-hierarchy derive tag parent) nil)
3348
+ ([h tag parent]
3349
+ (assert (not= tag parent))
3350
+ (assert (or (class? tag) (instance? clojure.lang.Named tag)))
3351
+ (assert (instance? clojure.lang.Named parent))
3352
+
3353
+ (let [tp (:parents h)
3354
+ td (:descendants h)
3355
+ ta (:ancestors h)
3356
+ tf (fn [m source sources target targets]
3357
+ (reduce (fn [ret k]
3358
+ (assoc ret k
3359
+ (reduce conj (get targets k #{}) (cons target (targets target)))))
3360
+ m (cons source (sources source))))]
3361
+ (or
3362
+ (when-not (contains? (tp tag) parent)
3363
+ (when (contains? (ta tag) parent)
3364
+ (throw (Exception. (print-str tag "already has" parent "as ancestor"))))
3365
+ (when (contains? (ta parent) tag)
3366
+ (throw (Exception. (print-str "Cyclic derivation:" parent "has" tag "as ancestor"))))
3367
+ {:parents (assoc (:parents h) tag (conj (get tp tag #{}) parent))
3368
+ :ancestors (tf (:ancestors h) tag td parent ta)
3369
+ :descendants (tf (:descendants h) parent ta tag td)})
3370
+ h))))
3371
+
3372
+ (defn underive
3373
+ "Removes a parent/child relationship between parent and
3374
+ tag. h must be a hierarchy obtained from make-hierarchy, if not
3375
+ supplied defaults to, and modifies, the global hierarchy."
3376
+ ([tag parent] (alter-var-root #'global-hierarchy underive tag parent) nil)
3377
+ ([h tag parent]
3378
+ (let [tp (:parents h)
3379
+ td (:descendants h)
3380
+ ta (:ancestors h)
3381
+ tf (fn [m source sources target targets]
3382
+ (reduce
3383
+ (fn [ret k]
3384
+ (assoc ret k
3385
+ (reduce disj (get targets k) (cons target (targets target)))))
3386
+ m (cons source (sources source))))]
3387
+ (if (contains? (tp tag) parent)
3388
+ {:parent (assoc (:parents h) tag (disj (get tp tag) parent))
3389
+ :ancestors (tf (:ancestors h) tag td parent ta)
3390
+ :descendants (tf (:descendants h) parent ta tag td)}
3391
+ h))))
3392
+
3393
+
3394
+ (defn distinct?
3395
+ "Returns true if no two of the arguments are ="
3396
+ {:tag Boolean}
3397
+ ([x] true)
3398
+ ([x y] (not (= x y)))
3399
+ ([x y & more]
3400
+ (if (not= x y)
3401
+ (loop [s #{x y} [x & etc :as xs] more]
3402
+ (if xs
3403
+ (if (contains? s x)
3404
+ false
3405
+ (recur (conj s x) etc))
3406
+ true))
3407
+ false)))
3408
+
3409
+ (defn resultset-seq
3410
+ "Creates and returns a lazy sequence of structmaps corresponding to
3411
+ the rows in the java.sql.ResultSet rs"
3412
+ [#^java.sql.ResultSet rs]
3413
+ (let [rsmeta (. rs (getMetaData))
3414
+ idxs (range 1 (inc (. rsmeta (getColumnCount))))
3415
+ keys (map (comp keyword #(.toLowerCase #^String %))
3416
+ (map (fn [i] (. rsmeta (getColumnLabel i))) idxs))
3417
+ check-keys
3418
+ (or (apply distinct? keys)
3419
+ (throw (Exception. "ResultSet must have unique column labels")))
3420
+ row-struct (apply create-struct keys)
3421
+ row-values (fn [] (map (fn [#^Integer i] (. rs (getObject i))) idxs))
3422
+ rows (fn thisfn []
3423
+ (lazy-seq
3424
+ (when (. rs (next))
3425
+ (cons (apply struct row-struct (row-values)) (thisfn)))))]
3426
+ (rows)))
3427
+
3428
+ (defn iterator-seq
3429
+ "Returns a seq on a java.util.Iterator. Note that most collections
3430
+ providing iterators implement Iterable and thus support seq directly."
3431
+ [iter]
3432
+ (clojure.lang.IteratorSeq/create iter))
3433
+
3434
+ (defn enumeration-seq
3435
+ "Returns a seq on a java.util.Enumeration"
3436
+ [e]
3437
+ (clojure.lang.EnumerationSeq/create e))
3438
+
3439
+ (defn format
3440
+ "Formats a string using java.lang.String.format, see java.util.Formatter for format
3441
+ string syntax"
3442
+ {:tag String}
3443
+ [fmt & args]
3444
+ (String/format fmt (to-array args)))
3445
+
3446
+ (defn printf
3447
+ "Prints formatted output, as per format"
3448
+ [fmt & args]
3449
+ (print (apply format fmt args)))
3450
+
3451
+ (def gen-class)
3452
+
3453
+ (defmacro ns
3454
+ "Sets *ns* to the namespace named by name (unevaluated), creating it
3455
+ if needed. references can be zero or more of: (:refer-clojure ...)
3456
+ (:require ...) (:use ...) (:import ...) (:load ...) (:gen-class)
3457
+ with the syntax of refer-clojure/require/use/import/load/gen-class
3458
+ respectively, except the arguments are unevaluated and need not be
3459
+ quoted. (:gen-class ...), when supplied, defaults to :name
3460
+ corresponding to the ns name, :main true, :impl-ns same as ns, and
3461
+ :init-impl-ns true. All options of gen-class are
3462
+ supported. The :gen-class directive is ignored when not
3463
+ compiling. If :gen-class is not supplied, when compiled only an
3464
+ nsname__init.class will be generated. If :refer-clojure is not used, a
3465
+ default (refer 'clojure) is used. Use of ns is preferred to
3466
+ individual calls to in-ns/require/use/import:
3467
+
3468
+ (ns foo.bar
3469
+ (:refer-clojure :exclude [ancestors printf])
3470
+ (:require (clojure.contrib sql sql.tests))
3471
+ (:use (my.lib this that))
3472
+ (:import (java.util Date Timer Random)
3473
+ (java.sql Connection Statement)))"
3474
+
3475
+ [name & references]
3476
+ (let [process-reference
3477
+ (fn [[kname & args]]
3478
+ `(~(symbol "clojure.core" (clojure.core/name kname))
3479
+ ~@(map #(list 'quote %) args)))
3480
+ docstring (when (string? (first references)) (first references))
3481
+ references (if docstring (next references) references)
3482
+ name (if docstring
3483
+ (with-meta name (assoc (meta name)
3484
+ :doc docstring))
3485
+ name)
3486
+ gen-class-clause (first (filter #(= :gen-class (first %)) references))
3487
+ gen-class-call
3488
+ (when gen-class-clause
3489
+ (list* `gen-class :name (.replace (str name) \- \_) :impl-ns name :main true (next gen-class-clause)))
3490
+ references (remove #(= :gen-class (first %)) references)]
3491
+ `(do
3492
+ (clojure.core/in-ns '~name)
3493
+ ~@(when gen-class-call (list gen-class-call))
3494
+ ~@(when (and (not= name 'clojure.core) (not-any? #(= :refer-clojure (first %)) references))
3495
+ `((clojure.core/refer '~'clojure.core)))
3496
+ ~@(map process-reference references))))
3497
+
3498
+ (defmacro refer-clojure
3499
+ "Same as (refer 'clojure.core <filters>)"
3500
+ [& filters]
3501
+ `(clojure.core/refer '~'clojure.core ~@filters))
3502
+
3503
+ (defmacro defonce
3504
+ "defs name to have the root value of the expr iff the named var has no root value,
3505
+ else expr is unevaluated"
3506
+ [name expr]
3507
+ `(let [v# (def ~name)]
3508
+ (when-not (.hasRoot v#)
3509
+ (def ~name ~expr))))
3510
+
3511
+ ;;;;;;;;;;; require/use/load, contributed by Stephen C. Gilardi ;;;;;;;;;;;;;;;;;;
3512
+
3513
+ (defonce
3514
+ #^{:private true
3515
+ :doc "A ref to a sorted set of symbols representing loaded libs"}
3516
+ *loaded-libs* (ref (sorted-set)))
3517
+
3518
+ (defonce
3519
+ #^{:private true
3520
+ :doc "the set of paths currently being loaded by this thread"}
3521
+ *pending-paths* #{})
3522
+
3523
+ (defonce
3524
+ #^{:private true :doc
3525
+ "True while a verbose load is pending"}
3526
+ *loading-verbosely* false)
3527
+
3528
+ (defn- throw-if
3529
+ "Throws an exception with a message if pred is true"
3530
+ [pred fmt & args]
3531
+ (when pred
3532
+ (let [#^String message (apply format fmt args)
3533
+ exception (Exception. message)
3534
+ raw-trace (.getStackTrace exception)
3535
+ boring? #(not= (.getMethodName #^StackTraceElement %) "doInvoke")
3536
+ trace (into-array (drop 2 (drop-while boring? raw-trace)))]
3537
+ (.setStackTrace exception trace)
3538
+ (throw exception))))
3539
+
3540
+ (defn- libspec?
3541
+ "Returns true if x is a libspec"
3542
+ [x]
3543
+ (or (symbol? x)
3544
+ (and (vector? x)
3545
+ (or
3546
+ (nil? (second x))
3547
+ (keyword? (second x))))))
3548
+
3549
+ (defn- prependss
3550
+ "Prepends a symbol or a seq to coll"
3551
+ [x coll]
3552
+ (if (symbol? x)
3553
+ (cons x coll)
3554
+ (concat x coll)))
3555
+
3556
+ (defn- root-resource
3557
+ "Returns the root directory path for a lib"
3558
+ {:tag String}
3559
+ [lib]
3560
+ (str \/
3561
+ (.. (name lib)
3562
+ (replace \- \_)
3563
+ (replace \. \/))))
3564
+
3565
+ (defn- root-directory
3566
+ "Returns the root resource path for a lib"
3567
+ [lib]
3568
+ (let [d (root-resource lib)]
3569
+ (subs d 0 (.lastIndexOf d "/"))))
3570
+
3571
+ (def load)
3572
+
3573
+ (defn- load-one
3574
+ "Loads a lib given its name. If need-ns, ensures that the associated
3575
+ namespace exists after loading. If require, records the load so any
3576
+ duplicate loads can be skipped."
3577
+ [lib need-ns require]
3578
+ (load (root-resource lib))
3579
+ (throw-if (and need-ns (not (find-ns lib)))
3580
+ "namespace '%s' not found after loading '%s'"
3581
+ lib (root-resource lib))
3582
+ (when require
3583
+ (dosync
3584
+ (commute *loaded-libs* conj lib))))
3585
+
3586
+ (defn- load-all
3587
+ "Loads a lib given its name and forces a load of any libs it directly or
3588
+ indirectly loads. If need-ns, ensures that the associated namespace
3589
+ exists after loading. If require, records the load so any duplicate loads
3590
+ can be skipped."
3591
+ [lib need-ns require]
3592
+ (dosync
3593
+ (commute *loaded-libs* #(reduce conj %1 %2)
3594
+ (binding [*loaded-libs* (ref (sorted-set))]
3595
+ (load-one lib need-ns require)
3596
+ @*loaded-libs*))))
3597
+
3598
+ (defn- load-lib
3599
+ "Loads a lib with options"
3600
+ [prefix lib & options]
3601
+ (throw-if (and prefix (pos? (.indexOf (name lib) (int \.))))
3602
+ "lib names inside prefix lists must not contain periods")
3603
+ (let [lib (if prefix (symbol (str prefix \. lib)) lib)
3604
+ opts (apply hash-map options)
3605
+ {:keys [as reload reload-all require use verbose]} opts
3606
+ loaded (contains? @*loaded-libs* lib)
3607
+ load (cond reload-all
3608
+ load-all
3609
+ (or reload (not require) (not loaded))
3610
+ load-one)
3611
+ need-ns (or as use)
3612
+ filter-opts (select-keys opts '(:exclude :only :rename))]
3613
+ (binding [*loading-verbosely* (or *loading-verbosely* verbose)]
3614
+ (if load
3615
+ (load lib need-ns require)
3616
+ (throw-if (and need-ns (not (find-ns lib)))
3617
+ "namespace '%s' not found" lib))
3618
+ (when (and need-ns *loading-verbosely*)
3619
+ (printf "(clojure.core/in-ns '%s)\n" (ns-name *ns*)))
3620
+ (when as
3621
+ (when *loading-verbosely*
3622
+ (printf "(clojure.core/alias '%s '%s)\n" as lib))
3623
+ (alias as lib))
3624
+ (when use
3625
+ (when *loading-verbosely*
3626
+ (printf "(clojure.core/refer '%s" lib)
3627
+ (doseq [opt filter-opts]
3628
+ (printf " %s '%s" (key opt) (print-str (val opt))))
3629
+ (printf ")\n"))
3630
+ (apply refer lib (mapcat seq filter-opts))))))
3631
+
3632
+ (defn- load-libs
3633
+ "Loads libs, interpreting libspecs, prefix lists, and flags for
3634
+ forwarding to load-lib"
3635
+ [& args]
3636
+ (let [flags (filter keyword? args)
3637
+ opts (interleave flags (repeat true))
3638
+ args (filter (complement keyword?) args)]
3639
+ (doseq [arg args]
3640
+ (if (libspec? arg)
3641
+ (apply load-lib nil (prependss arg opts))
3642
+ (let [[prefix & args] arg]
3643
+ (throw-if (nil? prefix) "prefix cannot be nil")
3644
+ (doseq [arg args]
3645
+ (apply load-lib prefix (prependss arg opts))))))))
3646
+
3647
+ ;; Public
3648
+
3649
+ (defn require
3650
+ "Loads libs, skipping any that are already loaded. Each argument is
3651
+ either a libspec that identifies a lib, a prefix list that identifies
3652
+ multiple libs whose names share a common prefix, or a flag that modifies
3653
+ how all the identified libs are loaded. Use :require in the ns macro
3654
+ in preference to calling this directly.
3655
+
3656
+ Libs
3657
+
3658
+ A 'lib' is a named set of resources in classpath whose contents define a
3659
+ library of Clojure code. Lib names are symbols and each lib is associated
3660
+ with a Clojure namespace and a Java package that share its name. A lib's
3661
+ name also locates its root directory within classpath using Java's
3662
+ package name to classpath-relative path mapping. All resources in a lib
3663
+ should be contained in the directory structure under its root directory.
3664
+ All definitions a lib makes should be in its associated namespace.
3665
+
3666
+ 'require loads a lib by loading its root resource. The root resource path
3667
+ is derived from the root directory path by repeating its last component
3668
+ and appending '.clj'. For example, the lib 'x.y.z has root directory
3669
+ <classpath>/x/y/z; root resource <classpath>/x/y/z/z.clj. The root
3670
+ resource should contain code to create the lib's namespace and load any
3671
+ additional lib resources.
3672
+
3673
+ Libspecs
3674
+
3675
+ A libspec is a lib name or a vector containing a lib name followed by
3676
+ options expressed as sequential keywords and arguments.
3677
+
3678
+ Recognized options: :as
3679
+ :as takes a symbol as its argument and makes that symbol an alias to the
3680
+ lib's namespace in the current namespace.
3681
+
3682
+ Prefix Lists
3683
+
3684
+ It's common for Clojure code to depend on several libs whose names have
3685
+ the same prefix. When specifying libs, prefix lists can be used to reduce
3686
+ repetition. A prefix list contains the shared prefix followed by libspecs
3687
+ with the shared prefix removed from the lib names. After removing the
3688
+ prefix, the names that remain must not contain any periods.
3689
+
3690
+ Flags
3691
+
3692
+ A flag is a keyword.
3693
+ Recognized flags: :reload, :reload-all, :verbose
3694
+ :reload forces loading of all the identified libs even if they are
3695
+ already loaded
3696
+ :reload-all implies :reload and also forces loading of all libs that the
3697
+ identified libs directly or indirectly load via require or use
3698
+ :verbose triggers printing information about each load, alias, and refer"
3699
+
3700
+ [& args]
3701
+ (apply load-libs :require args))
3702
+
3703
+ (defn use
3704
+ "Like 'require, but also refers to each lib's namespace using
3705
+ clojure.core/refer. Use :use in the ns macro in preference to calling
3706
+ this directly.
3707
+
3708
+ 'use accepts additional options in libspecs: :exclude, :only, :rename.
3709
+ The arguments and semantics for :exclude, :only, and :rename are the same
3710
+ as those documented for clojure.core/refer."
3711
+ [& args] (apply load-libs :require :use args))
3712
+
3713
+ (defn loaded-libs
3714
+ "Returns a sorted set of symbols naming the currently loaded libs"
3715
+ [] @*loaded-libs*)
3716
+
3717
+ (defn load
3718
+ "Loads Clojure code from resources in classpath. A path is interpreted as
3719
+ classpath-relative if it begins with a slash or relative to the root
3720
+ directory for the current namespace otherwise."
3721
+ [& paths]
3722
+ (doseq [#^String path paths]
3723
+ (let [#^String path (if (.startsWith path "/")
3724
+ path
3725
+ (str (root-directory (ns-name *ns*)) \/ path))]
3726
+ (when *loading-verbosely*
3727
+ (printf "(clojure.core/load \"%s\")\n" path)
3728
+ (flush))
3729
+ ; (throw-if (*pending-paths* path)
3730
+ ; "cannot load '%s' again while it is loading"
3731
+ ; path)
3732
+ (when-not (*pending-paths* path)
3733
+ (binding [*pending-paths* (conj *pending-paths* path)]
3734
+ (clojure.lang.RT/load (.substring path 1)))))))
3735
+
3736
+ (defn compile
3737
+ "Compiles the namespace named by the symbol lib into a set of
3738
+ classfiles. The source for the lib must be in a proper
3739
+ classpath-relative directory. The output files will go into the
3740
+ directory specified by *compile-path*, and that directory too must
3741
+ be in the classpath."
3742
+ [lib]
3743
+ (binding [*compile-files* true]
3744
+ (load-one lib true true))
3745
+ lib)
3746
+
3747
+ ;;;;;;;;;;;;; nested associative ops ;;;;;;;;;;;
3748
+
3749
+ (defn get-in
3750
+ "returns the value in a nested associative structure, where ks is a sequence of keys"
3751
+ [m ks]
3752
+ (reduce get m ks))
3753
+
3754
+ (defn assoc-in
3755
+ "Associates a value in a nested associative structure, where ks is a
3756
+ sequence of keys and v is the new value and returns a new nested structure.
3757
+ If any levels do not exist, hash-maps will be created."
3758
+ [m [k & ks] v]
3759
+ (if ks
3760
+ (assoc m k (assoc-in (get m k) ks v))
3761
+ (assoc m k v)))
3762
+
3763
+ (defn update-in
3764
+ "'Updates' a value in a nested associative structure, where ks is a
3765
+ sequence of keys and f is a function that will take the old value
3766
+ and any supplied args and return the new value, and returns a new
3767
+ nested structure. If any levels do not exist, hash-maps will be
3768
+ created."
3769
+ ([m [k & ks] f & args]
3770
+ (if ks
3771
+ (assoc m k (apply update-in (get m k) ks f args))
3772
+ (assoc m k (apply f (get m k) args)))))
3773
+
3774
+
3775
+ (defn empty?
3776
+ "Returns true if coll has no items - same as (not (seq coll)).
3777
+ Please use the idiom (seq x) rather than (not (empty? x))"
3778
+ [coll] (not (seq coll)))
3779
+
3780
+ (defn coll?
3781
+ "Returns true if x implements IPersistentCollection"
3782
+ [x] (instance? clojure.lang.IPersistentCollection x))
3783
+
3784
+ (defn list?
3785
+ "Returns true if x implements IPersistentList"
3786
+ [x] (instance? clojure.lang.IPersistentList x))
3787
+
3788
+ (defn set?
3789
+ "Returns true if x implements IPersistentSet"
3790
+ [x] (instance? clojure.lang.IPersistentSet x))
3791
+
3792
+ (defn ifn?
3793
+ "Returns true if x implements IFn. Note that many data structures
3794
+ (e.g. sets and maps) implement IFn"
3795
+ [x] (instance? clojure.lang.IFn x))
3796
+
3797
+ (defn fn?
3798
+ "Returns true if x implements Fn, i.e. is an object created via fn."
3799
+ [x] (instance? clojure.lang.Fn x))
3800
+
3801
+
3802
+ (defn associative?
3803
+ "Returns true if coll implements Associative"
3804
+ [coll] (instance? clojure.lang.Associative coll))
3805
+
3806
+ (defn sequential?
3807
+ "Returns true if coll implements Sequential"
3808
+ [coll] (instance? clojure.lang.Sequential coll))
3809
+
3810
+ (defn sorted?
3811
+ "Returns true if coll implements Sorted"
3812
+ [coll] (instance? clojure.lang.Sorted coll))
3813
+
3814
+ (defn counted?
3815
+ "Returns true if coll implements count in constant time"
3816
+ [coll] (instance? clojure.lang.Counted coll))
3817
+
3818
+ (defn reversible?
3819
+ "Returns true if coll implements Reversible"
3820
+ [coll] (instance? clojure.lang.Reversible coll))
3821
+
3822
+ (def
3823
+ #^{:doc "bound in a repl thread to the most recent value printed"}
3824
+ *1)
3825
+
3826
+ (def
3827
+ #^{:doc "bound in a repl thread to the second most recent value printed"}
3828
+ *2)
3829
+
3830
+ (def
3831
+ #^{:doc "bound in a repl thread to the third most recent value printed"}
3832
+ *3)
3833
+
3834
+ (def
3835
+ #^{:doc "bound in a repl thread to the most recent exception caught by the repl"}
3836
+ *e)
3837
+
3838
+ (defmacro declare
3839
+ "defs the supplied var names with no bindings, useful for making forward declarations."
3840
+ [& names] `(do ~@(map #(list 'def %) names)))
3841
+
3842
+ (defn trampoline
3843
+ "trampoline can be used to convert algorithms requiring mutual
3844
+ recursion without stack consumption. Calls f with supplied args, if
3845
+ any. If f returns a fn, calls that fn with no arguments, and
3846
+ continues to repeat, until the return value is not a fn, then
3847
+ returns that non-fn value. Note that if you want to return a fn as a
3848
+ final value, you must wrap it in some data structure and unpack it
3849
+ after trampoline returns."
3850
+ ([f]
3851
+ (let [ret (f)]
3852
+ (if (fn? ret)
3853
+ (recur ret)
3854
+ ret)))
3855
+ ([f & args]
3856
+ (trampoline #(apply f args))))
3857
+
3858
+ (defn intern
3859
+ "Finds or creates a var named by the symbol name in the namespace
3860
+ ns (which can be a symbol or a namespace), setting its root binding
3861
+ to val if supplied. The namespace must exist. The var will adopt any
3862
+ metadata from the name symbol. Returns the var."
3863
+ ([ns #^clojure.lang.Symbol name]
3864
+ (let [v (clojure.lang.Var/intern (the-ns ns) name)]
3865
+ (when ^name (.setMeta v ^name))
3866
+ v))
3867
+ ([ns name val]
3868
+ (let [v (clojure.lang.Var/intern (the-ns ns) name val)]
3869
+ (when ^name (.setMeta v ^name))
3870
+ v)))
3871
+
3872
+ (defmacro while
3873
+ "Repeatedly executes body while test expression is true. Presumes
3874
+ some side-effect will cause test to become false/nil. Returns nil"
3875
+ [test & body]
3876
+ `(loop []
3877
+ (when ~test
3878
+ ~@body
3879
+ (recur))))
3880
+
3881
+ (defn memoize
3882
+ "Returns a memoized version of a referentially transparent function. The
3883
+ memoized version of the function keeps a cache of the mapping from arguments
3884
+ to results and, when calls with the same arguments are repeated often, has
3885
+ higher performance at the expense of higher memory use."
3886
+ [f]
3887
+ (let [mem (atom {})]
3888
+ (fn [& args]
3889
+ (if-let [e (find @mem args)]
3890
+ (val e)
3891
+ (let [ret (apply f args)]
3892
+ (swap! mem assoc args ret)
3893
+ ret)))))
3894
+
3895
+ (defmacro condp
3896
+ "Takes a binary predicate, an expression, and a set of clauses.
3897
+ Each clause can take the form of either:
3898
+
3899
+ test-expr result-expr
3900
+
3901
+ test-expr :>> result-fn
3902
+
3903
+ Note :>> is an ordinary keyword.
3904
+
3905
+ For each clause, (pred test-expr expr) is evaluated. If it returns
3906
+ logical true, the clause is a match. If a binary clause matches, the
3907
+ result-expr is returned, if a ternary clause matches, its result-fn,
3908
+ which must be a unary function, is called with the result of the
3909
+ predicate as its argument, the result of that call being the return
3910
+ value of condp. A single default expression can follow the clauses,
3911
+ and its value will be returned if no clause matches. If no default
3912
+ expression is provided and no clause matches, an
3913
+ IllegalArgumentException is thrown."
3914
+
3915
+ [pred expr & clauses]
3916
+ (let [gpred (gensym "pred__")
3917
+ gexpr (gensym "expr__")
3918
+ emit (fn emit [pred expr args]
3919
+ (let [[[a b c :as clause] more]
3920
+ (split-at (if (= :>> (second args)) 3 2) args)
3921
+ n (count clause)]
3922
+ (cond
3923
+ (= 0 n) `(throw (IllegalArgumentException. (str "No matching clause: " ~expr)))
3924
+ (= 1 n) a
3925
+ (= 2 n) `(if (~pred ~a ~expr)
3926
+ ~b
3927
+ ~(emit pred expr more))
3928
+ :else `(if-let [p# (~pred ~a ~expr)]
3929
+ (~c p#)
3930
+ ~(emit pred expr more)))))
3931
+ gres (gensym "res__")]
3932
+ `(let [~gpred ~pred
3933
+ ~gexpr ~expr]
3934
+ ~(emit gpred gexpr clauses))))
3935
+
3936
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; var documentation ;;;;;;;;;;;;;;;;;;;;;;;;;;
3937
+
3938
+ (defmacro add-doc {:private true} [name docstring]
3939
+ `(alter-meta! (var ~name) assoc :doc ~docstring))
3940
+
3941
+ (add-doc *file*
3942
+ "The path of the file being evaluated, as a String.
3943
+
3944
+ Evaluates to nil when there is no file, eg. in the REPL.")
3945
+
3946
+ (add-doc *command-line-args*
3947
+ "A sequence of the supplied command line arguments, or nil if
3948
+ none were supplied")
3949
+
3950
+ (add-doc *warn-on-reflection*
3951
+ "When set to true, the compiler will emit warnings when reflection is
3952
+ needed to resolve Java method calls or field accesses.
3953
+
3954
+ Defaults to false.")
3955
+
3956
+ (add-doc *compile-path*
3957
+ "Specifies the directory where 'compile' will write out .class
3958
+ files. This directory must be in the classpath for 'compile' to
3959
+ work.
3960
+
3961
+ Defaults to \"classes\"")
3962
+
3963
+ (add-doc *compile-files*
3964
+ "Set to true when compiling files, false otherwise.")
3965
+
3966
+ (add-doc *ns*
3967
+ "A clojure.lang.Namespace object representing the current namespace.")
3968
+
3969
+ (add-doc *in*
3970
+ "A java.io.Reader object representing standard input for read operations.
3971
+
3972
+ Defaults to System/in, wrapped in a LineNumberingPushbackReader")
3973
+
3974
+ (add-doc *out*
3975
+ "A java.io.Writer object representing standard output for print operations.
3976
+
3977
+ Defaults to System/out")
3978
+
3979
+ (add-doc *err*
3980
+ "A java.io.Writer object representing standard error for print operations.
3981
+
3982
+ Defaults to System/err, wrapped in a PrintWriter")
3983
+
3984
+ (add-doc *flush-on-newline*
3985
+ "When set to true, output will be flushed whenever a newline is printed.
3986
+
3987
+ Defaults to true.")
3988
+
3989
+ (add-doc *print-meta*
3990
+ "If set to logical true, when printing an object, its metadata will also
3991
+ be printed in a form that can be read back by the reader.
3992
+
3993
+ Defaults to false.")
3994
+
3995
+ (add-doc *print-dup*
3996
+ "When set to logical true, objects will be printed in a way that preserves
3997
+ their type when read in later.
3998
+
3999
+ Defaults to false.")
4000
+
4001
+ (add-doc *print-readably*
4002
+ "When set to logical false, strings and characters will be printed with
4003
+ non-alphanumeric characters converted to the appropriate escape sequences.
4004
+
4005
+ Defaults to true")
4006
+
4007
+ (add-doc *read-eval*
4008
+ "When set to logical false, the EvalReader (#=(...)) is disabled in the
4009
+ read/load in the thread-local binding.
4010
+ Example: (binding [*read-eval* false] (read-string \"#=(eval (def x 3))\"))
4011
+
4012
+ Defaults to true")
4013
+
4014
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; helper files ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4015
+ (alter-meta! (find-ns 'clojure.core) assoc :doc "Fundamental library of the Clojure language")
4016
+ (load "core_proxy")
4017
+ (load "core_print")
4018
+ (load "genclass")
4019
+
4020
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; futures (needs proxy);;;;;;;;;;;;;;;;;;
4021
+ (defn future-call
4022
+ "Takes a function of no args and yields a future object that will
4023
+ invoke the function in another thread, and will cache the result and
4024
+ return it on all subsequent calls to deref/@. If the computation has
4025
+ not yet finished, calls to deref/@ will block."
4026
+ [#^Callable f]
4027
+ (let [fut (.submit clojure.lang.Agent/soloExecutor f)]
4028
+ (proxy [clojure.lang.IDeref java.util.concurrent.Future] []
4029
+ (deref [] (.get fut))
4030
+ (get ([] (.get fut))
4031
+ ([timeout unit] (.get fut timeout unit)))
4032
+ (isCancelled [] (.isCancelled fut))
4033
+ (isDone [] (.isDone fut))
4034
+ (cancel [interrupt?] (.cancel fut interrupt?)))))
4035
+
4036
+ (defmacro future
4037
+ "Takes a body of expressions and yields a future object that will
4038
+ invoke the body in another thread, and will cache the result and
4039
+ return it on all subsequent calls to deref/@. If the computation has
4040
+ not yet finished, calls to deref/@ will block."
4041
+ [& body] `(future-call (fn [] ~@body)))
4042
+
4043
+ (defn pmap
4044
+ "Like map, except f is applied in parallel. Semi-lazy in that the
4045
+ parallel computation stays ahead of the consumption, but doesn't
4046
+ realize the entire result unless required. Only useful for
4047
+ computationally intensive functions where the time of f dominates
4048
+ the coordination overhead."
4049
+ ([f coll]
4050
+ (let [n (+ 2 (.. Runtime getRuntime availableProcessors))
4051
+ rets (map #(future (f %)) coll)
4052
+ step (fn step [[x & xs :as vs] fs]
4053
+ (lazy-seq
4054
+ (if-let [s (seq fs)]
4055
+ (cons (deref x) (step xs (rest s)))
4056
+ (map deref vs))))]
4057
+ (step rets (drop n rets))))
4058
+ ([f coll & colls]
4059
+ (let [step (fn step [cs]
4060
+ (lazy-seq
4061
+ (let [ss (map seq cs)]
4062
+ (when (every? identity ss)
4063
+ (cons (map first ss) (step (map rest ss)))))))]
4064
+ (pmap #(apply f %) (step (cons coll colls))))))
4065
+
4066
+ (defn pcalls
4067
+ "Executes the no-arg fns in parallel, returning a lazy sequence of
4068
+ their values"
4069
+ [& fns] (pmap #(%) fns))
4070
+
4071
+ (defmacro pvalues
4072
+ "Returns a lazy sequence of the values of the exprs, which are
4073
+ evaluated in parallel"
4074
+ [& exprs]
4075
+ `(pcalls ~@(map #(list `fn [] %) exprs)))
4076
+
4077
+ (defmacro letfn
4078
+ "Takes a vector of function specs and a body, and generates a set of
4079
+ bindings of functions to their names. All of the names are available
4080
+ in all of the definitions of the functions, as well as the body.
4081
+
4082
+ fnspec ==> (fname [params*] exprs) or (fname ([params*] exprs)+)"
4083
+ [fnspecs & body]
4084
+ `(letfn* ~(vec (interleave (map first fnspecs)
4085
+ (map #(cons `fn %) fnspecs)))
4086
+ ~@body))
4087
+
4088
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; clojure version number ;;;;;;;;;;;;;;;;;;;;;;
4089
+
4090
+ (let [version-stream (.getResourceAsStream (clojure.lang.RT/baseLoader)
4091
+ "clojure/version.properties")
4092
+ properties (doto (new java.util.Properties) (.load version-stream))
4093
+ prop (fn [k] (.getProperty properties (str "clojure.version." k)))
4094
+ clojure-version {:major (Integer/valueOf (prop "major"))
4095
+ :minor (Integer/valueOf (prop "minor"))
4096
+ :incremental (Integer/valueOf (prop "incremental"))
4097
+ :qualifier (prop "qualifier")}]
4098
+ (def *clojure-version*
4099
+ (if (not (= (prop "interim") "false"))
4100
+ (clojure.lang.RT/assoc clojure-version :interim true)
4101
+ clojure-version)))
4102
+
4103
+ (add-doc *clojure-version*
4104
+ "The version info for Clojure core, as a map containing :major :minor
4105
+ :incremental and :qualifier keys. Feature releases may increment
4106
+ :minor and/or :major, bugfix releases will increment :incremental.
4107
+ Possible values of :qualifier include \"GA\", \"SNAPSHOT\", \"RC-x\" \"BETA-x\"")
4108
+
4109
+ (defn
4110
+ clojure-version
4111
+ "Returns clojure version as a printable string."
4112
+ []
4113
+ (str (:major *clojure-version*)
4114
+ "."
4115
+ (:minor *clojure-version*)
4116
+ (when-let [i (:incremental *clojure-version*)]
4117
+ (str "." i))
4118
+ (when-let [q (:qualifier *clojure-version*)]
4119
+ (str "-" q))
4120
+ (when (:interim *clojure-version*)
4121
+ "-SNAPSHOT")))