我从GitHub分叉了一个Scala库,我想将它导入另一个项目.
我怎么能告诉sbt在哪里找到这个包?
例如,我正在编写一个程序~/code/scala/myProgram,我想从中导入一个库~/code/scala/otherlib.
使用这个答案的代码,我有
(defn repeat-image [n string]
(println (apply str (repeat n string))))
(defn tile-image-across [x filename]
(with-open [rdr (reader filename)]
(doseq [line (line-seq rdr)]
(repeat-image x line))))
Run Code Online (Sandbox Code Playgroud)
...水平平铺ascii图像 现在,我怎么能"忽略"第一行?我这样做的原因是每个图像都有坐标(例如"20 63")作为第一行,我不需要该行.我尝试了一些方法(保持索引,模式匹配),但我的方法感觉做作.
我分叉了btce-scala,所以我可以在交易机器人上工作.我正在通过添加正常的sbt项目结构,制作build.sbt等来清理这个库:
~/code/scala/btce-scala) cat build.sbt
name := "btce-scala"
version := "0.1"
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
scalaVersion := "2.10.3"
libraryDependencies ++= Seq(
"net.liftweb" % "lift-json_2.9.1" % "2.6-M2",
"org.specs2" %% "specs2" % "2.3.8" % "test",
"joda-time" % "joda-time" % "2.3",
"org.joda" % "joda-convert" % "1.6",
"commons-codec" % "commons-codec" % "1.9",
"com.typesafe.play" % "play_2.2.2" % "2.2.2"
)
Run Code Online (Sandbox Code Playgroud)
我的问题是我不确定如何导入最新版本的Play框架.我需要它才能使用play.api.libs.ws.WS.
~/code/scala/btce-scala sbt run
[info] Set current project to btce-scala (in build file:/Users/bryangarza/code/scala/btce-scala/)
[info] Updating {file:/Users/bryangarza/code/scala/btce-scala/}btce-scala...
[info] Resolving com.typesafe.play#play_2.2.2;2.2.2 ...
[warn] …Run Code Online (Sandbox Code Playgroud) 出于某种原因,我从乘法函数中得到了奇怪的结果.这是该计划:
(ns scalc.core)
(defn add [numbers]
(reduce + numbers))
(defn sub [numbers]
(reduce - numbers))
(defn mul [numbers]
(reduce * numbers))
(defn div [numbers]
(reduce / numbers))
(defn numchoose []
(let [nums (re-seq #"\d+" (read-line))]
(map #(Float/parseFloat %) nums)))
(defn delegate []
(println "What operation would you like to do?: ")
(let [operation (read-line)]
(when (= operation "add")
(println "You chose to add.")
(println "What numbers? ")
(println (add (numchoose))))
(when (= operation "mul")
(println "You chose to multiply.")
(println …Run Code Online (Sandbox Code Playgroud)