use of clojure.lang.APersistentVector in project enumerable by hraberg.
the class ClojureTest method interactingWithEnumerableJava.
@SuppressWarnings("unchecked")
@Test
public void interactingWithEnumerableJava() throws Exception {
APersistentVector v = (APersistentVector) clj.eval("[1 2 3 4 5]");
IFn star = (IFn) clj.eval("*");
assertEquals(120L, Enumerable.inject(v, 1, toFn2(star)));
}
use of clojure.lang.APersistentVector in project enumerable by hraberg.
the class ClojureTest method creatingPersistentCollections.
@Test
public void creatingPersistentCollections() throws Exception {
APersistentVector vector = (APersistentVector) vec(list("hello", "world"));
assertEquals("hello", vector.invoke(0));
assertEquals("world", vector.invoke(1));
assertEquals("[\"hello\" \"world\"]", vector.toString());
APersistentSet set = (APersistentSet) set(list("hello", "world"));
assertEquals("hello", set.invoke("hello"));
assertEquals("world", set.invoke("world"));
assertEquals("#{\"hello\" \"world\"}", set.toString());
APersistentMap map = (APersistentMap) zipmap(list("hello", "world"), list(1, 2));
assertEquals(1, map.invoke("hello"));
assertEquals(2, map.invoke("world"));
assertEquals("{\"world\" 2, \"hello\" 1}", map.toString());
}
Aggregations