louise
The Louise language: compiler, runtime, std, tooling
Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.
Dernier runRéussi#115 · main · 21 min 41 s
0Étoiles
0Forks
40Issues
| 1 | // String interpolation (ADR 0034): `{e}` is `show(e)`, `{e:?}` is |
| 2 | // `debug(e)`, and the parts are joined once. |
| 3 | |
| 4 | import std/html.{type Html} |
| 5 | import std/io |
| 6 | import std/list |
| 7 | |
| 8 | @derive Show Debug |
| 9 | pub type Point { Point(x: Int, y: Int) } |
| 10 | |
| 11 | /// HTML text holes take any `Show` value, shown then escaped. |
| 12 | fn cell :: p: Point n: Int -> Html |
| 13 | { |
| 14 | <td>{n} is {p} in {"<b>"}</td> |
| 15 | } |
| 16 | |
| 17 | fn shown :: xs: List<Int> -> String |
| 18 | { |
| 19 | "{list.length xs} items, reversed {list.reverse xs:?}" |
| 20 | } |
| 21 | |
| 22 | pub fn main :: -> () / <io> |
| 23 | { |
| 24 | let name = "ada" |
| 25 | let p = Point(1, 2) |
| 26 | io.println "hello {name}, you are {36 + 1}" |
| 27 | io.println "{p} and {p:?} and {name:?}" |
| 28 | io.println (shown [3, 4]) |
| 29 | io.println "braces: \{ and \}, {if True { "nested" } else { "no" }}" |
| 30 | io.println "{1.5}{-2}{True}{()}{(1, "a")}" |
| 31 | io.println "" |
| 32 | io.println "\u{1F600} {name}" |
| 33 | io.println (html.render (cell p 3)) |
| 34 | } |
| 35 | //> hello ada, you are 37 |
| 36 | //> Point(1, 2) and Point { x: 1, y: 2 } and "ada" |
| 37 | //> 2 items, reversed [4, 3] |
| 38 | //> braces: { and }, nested |
| 39 | //> 1.5-2True()(1, a) |
| 40 | //> |
| 41 | //> 😀 ada |
| 42 | //> <td>3 is Point(1, 2) in <b></td> |