
突出显示的文本是我想要移动的数组.我必须在按下j之前按下g以向下移动一条线.我的.vimrc是否有一些映射,我可以使用hjkl在屏幕行中移动而不必每次都按g.
谢谢你的帮助Matthias
我正在编译Scala代码并在文件中写出输出控制台输出.我只想在文件中保存STDOUT的最后一行.这是命令:
scalac -Xplugin:divbyzero.jar Example.scala >> output.txt
Run Code Online (Sandbox Code Playgroud)
scalac -Xplugin:divbyzero.jar Example.scala的输出是:
helex@mg:~/git-repositories/my_plugin$ scalac -Xplugin:divbyzero.jar Example.scala | tee -a output.txt
You have overwritten the standard meaning
Literal:()
rhs type: Int(1)
Constant Type: Constant(1)
We have a literal constant
List(localhost.Low)
Constant Type: Constant(1)
Literal:1
rhs type: Int(2)
Constant Type: Constant(2)
We have a literal constant
List(localhost.High)
Constant Type: Constant(2)
Literal:2
rhs type: Boolean(true)
Constant Type: Constant(true)
We have a literal constant
List(localhost.High)
Constant Type: Constant(true)
Literal:true
LEVEL: H
LEVEL: H
okay
LEVEL: H
okay …Run Code Online (Sandbox Code Playgroud) 我正在尝试解释Scala中的字符串来定义类和方法.我在以下代码中使用了http://scala-programming-language.1934581.n4.nabble.com/Compiling-a-Scala-Snippet-at-run-time-td2000704.html中的示例:
import scala.tools.nsc.{Interpreter,Settings}
var i = new Interpreter(new Settings(str => println(str)))
i.interpret("class Test { def hello = \"Hello World\"}")
Run Code Online (Sandbox Code Playgroud)
它工作,但不知何故,解释结果不会发生在全局命名空间:
new Test # => <console>:5: error: not found: type Test
Run Code Online (Sandbox Code Playgroud)
因此:如何执行解释器语句以便在全局范围内定义结果?我目前正在使用scala2.7.7final,并且无法将解释器更改为2.8.
谢谢你的帮助
马蒂亚斯
我在〜/ my_files/test.tex下有一个文档,想要在test.tex中包含一些样式信息,可以在〜/ latex/styles/info_hypersetup.tex下找到.
当我在test.tex中包含以下语句时:
%% setting the infos for the pdf
\include{home/helex/latex/styles/info_hypersetup.tex}
Run Code Online (Sandbox Code Playgroud)
运行pdflatex test.test时出现以下错误:
! I can't write on file `~/latex/styles/info_hypersetup.tex.aux'.
Run Code Online (Sandbox Code Playgroud)
我将权限设置为777但这并没有改变任何东西.如果我将info_hypersetup.tex放在test.tex所在的目录结构中,它就可以工作.但我希望将此样式信息用作我所有文档的全局设置,并且不希望将其复制到每个项目中.
谢谢你的帮助.
我的.bashrc中有以下命令:
alias mfigpdf='for FIG in *.fig; do fig2dev -L pdftex "$FIG" "${FIG%.*}.pdftex"; done;
for FIG in *.fig; do fig2dev -L pstex_t -p "${FIG%.*}.pdftex" "$FIG" "${FIG%.*}.pdftex_t"; done'
Run Code Online (Sandbox Code Playgroud)
我想在我的Rakefile中执行'mfigpdf'命令:
desc "convert all images to pdftex (or png)"
task :pdf do
sh "mfigpdf"
system "mfigpdf"
end
Run Code Online (Sandbox Code Playgroud)
但这些任务都没有奏效.我可以在rakefile中复制命令,将它插入一个shellscript文件中,但是我有重复的代码.
谢谢你的帮助!
马蒂亚斯
我正在寻找Scala中所有钩子的简明文档.钩子是程序流程中可以截获常见行为的任何情况.这种情况包括:
我来自Ruby背景,例如,method_missing允许拦截不存在的方法调用.
Scala中是否有这样的钩子?
马蒂亚斯
实际上我正在根据http://www.scala-lang.org/node/140上的文章为Scala开发一个编译器插件.
这是插件的代码:
package localhost
import scala.tools.nsc
import nsc.Global
import nsc.Phase
import nsc.plugins.Plugin
import nsc.plugins.PluginComponent
class DivByZero(val global: Global) extends Plugin {
import global._
val name = "divbyzero"
val description = "checks for division by zero"
val components = List[PluginComponent](Component)
private object Component extends PluginComponent {
val global: DivByZero.this.global.type = DivByZero.this.global
val runsAfter = "refchecks"
// Using the Scala Compiler 2.8.x the runsAfter should be written as below
// val runsAfter = List[String]("refchecks");
val phaseName = DivByZero.this.name
def newPhase(_prev: …Run Code Online (Sandbox Code Playgroud) 我有以下代码:
if (element.matches("class Int"))
true
else
false
Run Code Online (Sandbox Code Playgroud)
是否可以使用类似*.getOrElse for Sets的函数来获得更清晰的代码?
我有以下代码:
def updateProgrammcounter(element: Name) {
val level = findSecurityLevelOfNameInSymboltable(element.toString.trim)
var pc = new HashSet[String]
println("LEVEL: " + level)
if (pc.isEmpty && level != "N") {
// the pc is empty so add the level
pc += level
} else if (pc.contains("H") && level == "L") {
// giving high information to low is not allowed
errorReject()
} else if (pc.contains("L") && level == "L") {
// nothing to change because the pc is the same
println("okay")
} else if (pc.contains("H") …Run Code Online (Sandbox Code Playgroud) 有人可以用抽象的方式向我解释这个术语,然后给我举一个小例子。我认为它与编译器的前端和后端以及阶段的执行方式有关。我很难用自己的语言来描述它。
感谢您的回复Matthias
我想在键之后搜索hashmap,如果找到键,则给出键的找到值的最后一个值.这是我到目前为止的解决方案:
import scala.collection.mutable.HashMap
object Tmp extends Application {
val hashmap = new HashMap[String, String]
hashmap += "a" -> "288 | object | L"
def findNameInSymboltable(name: String) = {
if (hashmap.get(name) == None)
"N"
else
hashmap.get(name).flatten.last.toString
}
val solution: String = findNameInSymboltable("a")
println(solution) // L
}
Run Code Online (Sandbox Code Playgroud)
是否有一种功能性的风格可以节省我的本地开销?