Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save xuwei-k/992247 to your computer and use it in GitHub Desktop.
Save xuwei-k/992247 to your computer and use it in GitHub Desktop.
Scala2.9.0のREPLをオレオレ仕様にカスタマイズ
Welcome to Scala version 2.9.0.r0-b20110520175005 (Java HotSpot(TM) Client VM, Java 1.6.0_22).
Type in expressions to have them evaluated.
Type :help for more information.
scala> :power
** Power User mode enabled - BEEP BOOP WHIR **
** scala.tools.nsc._ has been imported **
** global._ and definitions._ also imported **
** New vals! Try repl, intp, global, power **
** New cmds! :help to discover them **
** New defs! Type power.<tab> to reveal **
scala> repl.setPrompt("java> ")
java> 1 to 10 toList
res1: List[Int] = List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
java> repl.setPrompt("あばばばばば")
あばばばばば1
res3: Int = 1
あばばばばば
Welcome to Scala version 2.9.0.r0-b20110520175005 (Java HotSpot(TM) Client VM, Java 1.6.0_22).
Type in expressions to have them evaluated.
Type :help for more information.
scala> :power
** Power User mode enabled - BEEP BOOP WHIR **
** scala.tools.nsc._ has been imported **
** global._ and definitions._ also imported **
** New vals! Try repl, intp, global, power **
** New cmds! :help to discover them **
** New defs! Type power.<tab> to reveal **
scala> def t[A](p : => A):A = {
import java.util.Calendar._
val c = getInstance
repl.setPrompt(
Seq(HOUR,MINUTE,SECOND,MILLISECOND).map{c.get _}.mkString("",":","> ")
)
p
}
t: [A](p: => A)A
scala> :wrap t
Set wrapper to 't'
scala> 1 to 10 toList
res0: List[Int] = List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
9:16:7:345> 3
res1: Int = 3
9:16:21:861>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment