If you're interested in functional programming, you might also want to checkout my second blog which i'm actively working on!!

Saturday, October 12, 2013

Records and tuples as syntactic sugar for records (ML)

val product1 = {name="Iphone 5", price=400, madeByApple=true};
val productname = #name product1;
(* tuples are just syntactic sugar for records *)
val product2 = {1="GalaxyS4", 2=400};
val price = #2 product2;
(* output of program
- use "records.sml";
[opening records.sml]
val product1 = {madeByApple=true,name="Iphone 5",price=400}
: {madeByApple:bool, name:string, price:int}
val productname = "Iphone 5" : string
val product2 = ("GalaxyS4",400) : string * int
val price = 400 : int
val it = () : unit
*)
view raw gistfile1.sml hosted with ❤ by GitHub

No comments:

Post a Comment