tobogganSe connecter

louise

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

61 lignes · 1793 octetsBrut · Historique
1import std/io
2import std/string
3
4pub fn main :: -> () / <io>
5{
6 io.println (show (string.split "a,b,,c" ","))
7 io.println (show (string.to_int "-42") <> " " <> show (string.to_int "4x"))
8 io.println ("[" <> string.trim " padded \n" <> "]")
9 io.println (string.to_lower "Content-LENGTH")
10 io.println
11 ( show (string.byte_length "héllo") <> " bytes, "
12 <> show (string.length "héllo")
13 <> " chars"
14 )
15 io.println
16 ( show (string.starts_with "louise" "lou") <> " "
17 <> show (string.ends_with "louise" "se")
18 <> " "
19 <> show (string.contains "louise" "uis")
20 )
21 // string.find: the byte index of the first occurrence (Some) or None.
22 io.println
23 ( show (string.find "louise" "uis") <> " "
24 <> show (string.find "louise" "e")
25 <> " "
26 <> show (string.find "louise" "x")
27 )
28 io.println
29 ( show (string.find "héllo" "llo") <> " " <> show (string.find "hello" "")
30 <> " "
31 <> show (string.find "aaaa" "aa")
32 <> " "
33 <> show (string.find "ab" "abc")
34 )
35 // string.slice: by characters, bounds clamped to 0..length.
36 io.println (string.slice "hello" 1 4)
37 io.println (string.slice "héllo" 1 3 <> " " <> string.slice "日本語" 1 2)
38 io.println ("[" <> string.slice "héllo" (-3) 100 <> "]")
39 io.println
40 ( "[" <> string.slice "héllo" 3 100 <> " " <> string.slice "héllo" 0 2
41 <> "]"
42 )
43 io.println
44 ( "[" <> string.slice "héllo" 4 2 <> string.slice "héllo" 5 5
45 <> string.slice "" 0 1
46 <> "]"
47 )
48}
49//> [a, b, , c]
50//> Ok(-42) Error(not an integer: "4x")
51//> [padded]
52//> content-length
53//> 6 bytes, 5 chars
54//> True True True
55//> Some(2) Some(5) None
56//> Some(3) Some(0) Some(0) None
57//> ell
58//> él 本
59//> [héllo]
60//> [lo hé]
61//> []