I'm having trouble converting a Clojure Seq to a Scala Seq. it seems like there should be an easy way to do this.
(let [animals ["dog" "cat" "pig"]]
(to-scala-seq animals))
My goal is to use twitter's algebird in a Clojure project.
Because Clojure and Scala both run on the JVM, this is fairly straight-forward:
(ns scala-from-clojure.core
(:import (scala.collection JavaConversions)))
(defn to-scala-seq [coll]
(-> coll JavaConversions/asScalaBuffer .toList))
At the REPL
user=> (use 'scala-from-clojure.core)
nil
user=> (to-scala-seq [1 2 3])
#<$colon$colon List(1, 2, 3)>
user=> (instance? scala.collection.immutable.Seq *1)
true
See
How to create a scala.collection.immutable.Seq from a Java List in Java?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With