Skip to content

Instantly share code, notes, and snippets.

@pfcoperez
Created October 6, 2021 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pfcoperez/41aa641c516f8d8286058bfd77380214 to your computer and use it in GitHub Desktop.
Save pfcoperez/41aa641c516f8d8286058bfd77380214 to your computer and use it in GitHub Desktop.
A quine using Scala as an Ammonite script
var l = Vector.empty[String]
val c = '"'
def doit(p: => Unit) {
p
val ll = "doit {" +: l :+ "}"
print(ll.mkString("\n"))
}
def myprint(x: Any) {
l = l :+ s"myprint($c$c$c$x$c$c$c)"
println(x)
}
doit {
myprint("""var l = Vector.empty[String]
val c = '"'
def doit(p: => Unit) {
p
val ll = "doit {" +: l :+ "}"
print(ll.mkString("\n"))
}
def myprint(x: Any) {
l = l :+ s"myprint($c$c$c$x$c$c$c)"
println(x)
}""")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment