tobogganSe connecter

louise

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

30 lignes · 783 octetsBrut · Historique
1//@ small-stack
2// string.repeat doubles its copies: linear in the result, and a large
3// count needs only about log2(count) frames (it once took one per copy).
4
5import std/io
6import std/list
7import std/string
8
9pub fn main :: -> () / <io>
10{
11 io.println (string.repeat "ab" 3)
12 io.println
13 ( "[" <> string.repeat "x" 0 <> string.repeat "x" (-2) <> string.repeat "" 5
14 <> "]"
15 )
16 io.println (string.repeat "é" 5)
17 let counts = list.range 0 17
18 let right =
19 list.all counts fn n { string.byte_length (string.repeat "abc" n) == 3 * n }
20 io.println (show right)
21 let big = string.repeat "ab" 1000000
22 io.println (show (string.byte_length big))
23 io.println (string.slice big 1999990 2000000)
24}
25//> ababab
26//> []
27//> ééééé
28//> True
29//> 2000000
30//> ababababab