Skip to content

Instantly share code, notes, and snippets.

@missingfaktor
Created March 16, 2012 10:38
Show Gist options
  • Select an option

  • Save missingfaktor/2049508 to your computer and use it in GitHub Desktop.

Select an option

Save missingfaktor/2049508 to your computer and use it in GitHub Desktop.
val commands = Seq(
real_('a) := Real(20.0),
real_('b) := Real(11.0),
real_('c) := 'a * 'b,
int_('d) := 'a.as[Real] ° (_.toInt + 2),
string_('e) := ('a.as[Real] ⊛ 'b.as[Real])(_ + "lalala" + _)
)
val results = commands.foldLeft(Map.empty[Symbol, Any]) { case (r, c) =>
r + (c.sym -> c.expr.eval(r))
}
results must_== Map(
'a -> Real(20.0),
'b -> Real(11.0),
'c -> Real(220.0),
'd -> 22,
'e -> "20.0lalala11.0"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment