This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

mlang / examples / samples.mlg
1.7 kB 41 lines
1let inc = fun (x : Int) => x + 1 in inc 41; 21.25; 31.25 = 1.250; 45 / 2; 51 + 2.5; 6toInt 2; 7toDecimal (1 / 2); 8rationalStability (1 / 3); 9decimalStability (1 / 3); 10approx (sqrt 2.0) 4; 11bounds (sqrt 2.0) 4; 12approx (sqrt 2.0 + 3.0) 4; 13approx pi 4; 14approx (pi + 1.0) 4; 15lazyRationalStability pi; 16lazyDecimalStability (sqrt 2.0); 17let x = 10 in let f = fun (y : Int) => x + y in let x = 100 in f 5; 18if 6 * 7 = 42 then 1 else 0; 1910 / 2; 20readFile "examples/sample.ncl"; 21readFileNickel "examples/sample.ncl"; 22parseNickel "{ answer = 42, flags = [true, false], note = \"ok\" }"; 23parseJson "{\"answer\":42,\"flags\":[true,false],\"note\":\"ok\",\"empty\":null}"; 24parseJson "{\"price\":12.50,\"tax\":0.075}"; 25{ answer = 42, flags = [true, false], note = "ok", empty = null }; 26{ price = 12.50, tax = 0.075 }; 27toJson (parseNickel "{ answer = 42, flags = [true, false], note = \"ok\" }"); 28toJson (parseJson "{\"answer\":42,\"flags\":[true,false],\"note\":\"ok\",\"empty\":null}"); 29toJson { answer = 42, flags = [true, false], note = "ok", empty = null }; 30toNickel (parseJson "{\"answer\":42,\"flags\":[true,false],\"note\":\"ok\",\"odd key\":null}"); 31get (parseNickel "{ answer = 42, flags = [true, false] }") "answer"; 32get (parseJson "{\"answer\":42,\"flags\":[true,false]}") "answer"; 33get (parseJson "{\"price\":12.50}") "price"; 34get { answer = 42, flags = [true, false] } "answer"; 35at (get (parseNickel "{ flags = [true, false] }") "flags") 1; 36-> "examples/sample.ncl" readFileNickel (get "answer"); 37-> "{ flags = [true, false] }" parseNickel (get "flags") (at 1); 38pmap x in parseNickel "[{ answer = 1 }, { missing = 2 }, { answer = 3 }]" => get x "answer"; 39try 10 / 0 with err => 99; 401 + (try 10 / 0 with err => 4); 41httpGet "https://example.com"