Skip to content

Instantly share code, notes, and snippets.

@samskivert
Created December 15, 2010 23:06
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 samskivert/742752 to your computer and use it in GitHub Desktop.
Save samskivert/742752 to your computer and use it in GitHub Desktop.
Readability
case class Command (name :String, callsOtherCode :Boolean)
case class Procedure (name :String, commands :List[Command])
case class Activation (procedure :Procedure, parent :Option[Activation], returnAddress :Int) {
def parentCmdName :Option[String] =
parent map(_.procedure.commands(returnAddress)) filter(_.callsOtherCode) map(_.name)
}
def callStack (act :Activation) :List[String] =
List(act.procedure.name) ++ act.parentCmdName ++ act.parent.map(callStack).flatten
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment