Last active
December 16, 2015 11:29
-
-
Save jneira/5427618 to your computer and use it in GitHub Desktop.
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
def list=[1,"nan",new Whatever()] // neat! | |
def nan="nan" | |
def one=1 | |
one+nan | |
"1nan" | |
one-nan | |
// No signature of method: java.lang.Integer.minus() is applicable for argument types: (java.lang.String) | |
Object nan2="nan2" | |
Object two=2 | |
two+nan2==((Integer)two).plus((String)nan2) | |
//"2nan2" |
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
module Dyn where | |
data Dyn=DynInt Int | DynStr String -- | all types you want | |
deriving Show | |
plus (DynInt x) (DynInt y)=DynInt $ x+y | |
plus (DynStr x) (DynInt y)=DynStr $ x++(show y) | |
plus (DynInt x) (DynStr y)=DynStr $ (show x)++y | |
minus (DynInt x) (DynInt y)=DynInt $ x-y | |
minus (DynStr x) (DynInt y)=undefined -- ??? | |
minus (DynInt x) (DynStr y)=undefined -- ??? | |
dynaList :: [Dyn] | |
dynaList = [DynInt 1,DynStr "nan"] | |
dynamicGoodnessQMark = plus (DynInt 1) (DynStr "nan") | |
bang=minus (DynInt 3) (DynStr "nan") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment