Created
February 6, 2015 17:50
-
-
Save ufcpp/ff2b41792a320b64b89a to your computer and use it in GitHub Desktop.
decomposition of data types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // composition | |
| var expr = Add(Mult(Const(2), X()), Const(1)); | |
| // decomposition | |
| switch (expr) | |
| { | |
| case Add(Mult(var a, var x), var b): ...; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| abstract class Expr; | |
| class X() : Expr; | |
| class Const(double Value) : Expr; | |
| class Add(Expr Left, Expr Right) : Expr; | |
| class Mult(Expr Left, Expr Right) : Expr; | |
| class Neg(Expr Value) : Expr; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment