examples.json (1590B)
1 [ 2 { 3 "id": "identity", 4 "title": "Return a value", 5 "source": "!export answer\n\nidentity x = x\nanswer = identity 42\n", 6 "expression": "answer", 7 "output": "number", 8 "mode": "pure", 9 "expected": "42", 10 "terminal": "" 11 }, 12 { 13 "id": "arithmetic", 14 "title": "Define and apply a function", 15 "source": "!import {{native-math}} as N\n!export answer\n\ndouble n = N.multiply n 2\nanswer = double 21\n", 16 "expression": "answer", 17 "output": "number", 18 "mode": "pure", 19 "expected": "42", 20 "terminal": "" 21 }, 22 { 23 "id": "lists", 24 "title": "Transform and format a list", 25 "source": "!import {{base}} as B\n!import {{conversions}} as C\n!export answer\n\nanswer = B.intercalate \", \" (B.map C.showNumber [2 4 8])\n", 26 "expression": "answer", 27 "output": "string", 28 "mode": "pure", 29 "expected": "2, 4, 8", 30 "terminal": "" 31 }, 32 { 33 "id": "patterns", 34 "title": "Inspect a value with ordered equations", 35 "source": "!export answer\n\nfirstOr fallback [] = fallback\nfirstOr fallback [head | tail] = head\nfirstOr fallback _ = fallback\nanswer = firstOr 99 [7 9]\n", 36 "expression": "answer", 37 "output": "number", 38 "mode": "pure", 39 "expected": "7", 40 "terminal": "" 41 }, 42 { 43 "id": "text-io", 44 "title": "Sequence text output and return a value", 45 "source": "!import {{io}} as IO\n!export main\n\nmain = IO.io (do IO.bind\n IO.putStr \"Hello\\n\"\n IO.pure \"done\")\n", 46 "expression": "main", 47 "output": "string", 48 "mode": "io", 49 "expected": "done", 50 "terminal": "Hello\n" 51 } 52 ]