Search in sources :

Example 1 with APersistentVector

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)));
}
Also used : IFn(clojure.lang.IFn) APersistentVector(clojure.lang.APersistentVector) GroovyTest(org.enumerable.lambda.support.groovy.GroovyTest) ScalaTest(org.enumerable.lambda.support.scala.ScalaTest) JRubyTest(org.enumerable.lambda.support.jruby.JRubyTest) Test(org.junit.Test) JavaScriptTest(org.enumerable.lambda.support.javascript.JavaScriptTest)

Example 2 with APersistentVector

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());
}
Also used : APersistentVector(clojure.lang.APersistentVector) APersistentMap(clojure.lang.APersistentMap) APersistentSet(clojure.lang.APersistentSet) GroovyTest(org.enumerable.lambda.support.groovy.GroovyTest) ScalaTest(org.enumerable.lambda.support.scala.ScalaTest) JRubyTest(org.enumerable.lambda.support.jruby.JRubyTest) Test(org.junit.Test) JavaScriptTest(org.enumerable.lambda.support.javascript.JavaScriptTest)

Aggregations

APersistentVector (clojure.lang.APersistentVector)2 GroovyTest (org.enumerable.lambda.support.groovy.GroovyTest)2 JavaScriptTest (org.enumerable.lambda.support.javascript.JavaScriptTest)2 JRubyTest (org.enumerable.lambda.support.jruby.JRubyTest)2 ScalaTest (org.enumerable.lambda.support.scala.ScalaTest)2 Test (org.junit.Test)2 APersistentMap (clojure.lang.APersistentMap)1 APersistentSet (clojure.lang.APersistentSet)1 IFn (clojure.lang.IFn)1