tobogganSe connecter

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.

42 lignes · 1075 octetsBrut · Historique
1// String interpolation (ADR 0034): `{e}` is `show(e)`, `{e:?}` is
2// `debug(e)`, and the parts are joined once.
3
4import std/html.{type Html}
5import std/io
6import std/list
7
8@derive Show Debug
9pub type Point { Point(x: Int, y: Int) }
10
11/// HTML text holes take any `Show` value, shown then escaped.
12fn cell :: p: Point n: Int -> Html
13{
14 <td>{n} is {p} in {"<b>"}</td>
15}
16
17fn shown :: xs: List<Int> -> String
18{
19 "{list.length xs} items, reversed {list.reverse xs:?}"
20}
21
22pub 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 &lt;b&gt;</td>