Commit a03e3d7993a0af864487ba2fe3d729b91a29f8be

Thomas de Grivel 2024-09-10T22:42:14

doc: replace space with '_'

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
diff --git a/.ikc3_history b/.ikc3_history
index 13d2a34..dda62a2 100644
--- a/.ikc3_history
+++ b/.ikc3_history
@@ -1,4 +1,3 @@
-a = 1; 2
 a = ?; 2
 a
 a = ?; 2
@@ -97,3 +96,4 @@ List.sort([1, 2, 3, 4])
 List.sort([4, 3, 2, 1])
 List.sort(["1. a", "2. bc", "3. cde", "4. fghi"])
 List.sort(["1. abcd", "2. efg", "3. hi", "4. j"])
+license()
diff --git a/doc/1 KC3/1.1 Introduction.en.md b/doc/1 KC3/1.1 Introduction.en.md
deleted file mode 100644
index 00e45ab..0000000
--- a/doc/1 KC3/1.1 Introduction.en.md
+++ /dev/null
@@ -1,65 +0,0 @@
-# 1 Introduction
-
-KC3 is currently a programming language project, inspired by C, Elixir
-and Common Lisp. It could be described as C with Elixir modules,
-pattern matching, and a semantic object system. The idea is to plug
-modules, closures, pattern matching, a graph database and
-metaprogramming into C99 with an extremely small set of dependencies.
-
-Supported operating systems (additionnal dependencies) :
- - BSD
- - Linux (libbsd, libmd)
- - MacOS X (libmd)
- - Windows (MSys2)
-
-Supported architectures :
- - aarch64 (arm64, Apple M1, Apple M2)
- - amd64
- - i386
- - sparc64
-
-
-## 1.1 Modules
-
-Everything in KC3 is in a module. A module is a namespace,
-and is named with a symbol starting with a uppercase character.
-For instance `Sym` and `Str` are valid module names.
-
-Each module can define a type and a module name can also be a
-type name if the corresponding module defines a type.
-
-The module can also include definitions for functions for
-operating on the module type or other types.
-
-The default module is `KC3`, which is defined as facts (triples)
-in `lib/kc3/0.1/kc3.facts`.
-
-
-## 1.2 Data types
-
-Basic data types in KC3 are :
- - Strings : `Str`, e.g. `"Hello, world !"`
- - Symbols : `Sym`, e.g. `:hello` or `Hello`
- - Booleans : `Bool`, `true` or `false`
- - Numbers
-   - Integers
-     - Small integers
-       - Signed small integers : `S8`, `S16`, `S32`, `S64`, `Sw`
-       - Unsigned small integers : `U8`, `U16`, `U32`, `U64`, `Uw`
-     - Large integers : `Integer`
-   - Rational numbers (fractions of integers) : `Ratio`, e.g. `-2/3`
-   - Floating point numbers : `F32`, `F64`, `F128`
-   - Complex numbers (i = √(-1)) : `Complex`, e.g. `1 +i 2`
- - Lists : `List`, e.g. `[1, 2, 3]`
- - Tuples : `Tuple`, e.g. `{:ok, 123}`
- - Maps : `Map`, e.g. `%{id: 1, login: "dx"}`
- - Structs : e.g. `%GL.Sphere{}`
- - Quoted code : `Quote`, e.g. `quote 1 + 2`
- - Identifiers : `Ident`, e.g. `quote hello`
- - Function or operator call : `Call`, e.g. `quote sqrt(1)`, `quote 1 + 2`
- - Code blocks : `Block`, e.g. `{ 1 + 2; 3 + 4 }`
- - Function : `Fn`, e.g. `fn (x) { x * 2 }`
- - C function : `Cfn`, e.g. `cfn Tag "tag_add" (Tag, Tag, Result)`
- - Unquoted code: `Unquote`, e.g. `quote 1 + unquote(x)`
- - Variables : `Var`, e.g. `?`
- - Void : `Void`, e.g. `void`
diff --git a/doc/1 KC3/1.2 Integer.en.md b/doc/1 KC3/1.2 Integer.en.md
deleted file mode 100644
index 4b6b2b4..0000000
--- a/doc/1 KC3/1.2 Integer.en.md
+++ /dev/null
@@ -1,128 +0,0 @@
-# 2 Integers
-
-## 2.1 Small integers
-
-IKC3 supports all C integer type sizes from `U8` (matching the C type `uint8_t`)
-to `U64` (matching the C type `uint64_t`) for unsigned integers,
-and from `S8` to `S64` for signed integers.
-
-In addition to these 8 basic integer types there are 2 pointer-sized
-integer types :
-`Uw` for unsigned pointer-sized integers,
-and `Sw` for signed pointer-sized integers.
-
-Small integers take little space, are static, they are passed directly and
-not as a pointer, and for these reasons are fast.
-
-They do not need to be cleaned after use and thus can be used in arrays like
-is usually done in C.
-
-```
-ikc3> type(-1)
-S8
-ikc3> type(-128)
-S16
-ikc3> type(-32768)
-S32
-ikc3> type(-2147483648)
-S64
-ikc3> type(-9223372036854775807)
-S64
-ikc3> type(0)
-U8
-ikc3> type(256)
-U16
-ikc3> type(65536)
-U32
-ikc3> type(4294967296)
-U64
-ikc3> type(18446744073709551615)
-U64
-```
-
-## 2.2 Large integers
-
-IKC3 supports large integers and they are compatible with small integers.
-Their type is `Integer` and can support numbers as large as memory allows.
-They are slow because they are allocated dynamically on the heap
-using malloc.
-
-```
-ikc3> type(1000000000000000000000000000000)
-Integer
-```
-
-
-## 2.3 Operations on integers
-
-### 2.3.1 Operator `~`
-
-Binary not.
-
-```
-ikc3> ~ 1
-254
-ikc3> ~ -1
-0
-ikc3> ~ 0
-255
-ikc3> ~ 255
-0
-ikc3> ~ (U16) 1
-65534
-ikc3> ~ (S16) 1
--2
-```
-
-### 2.3.2 Operator `+`
-
-Integer addition.
-
-All positive integers can be defined in terms of addition of :
-zero or a positive integer, and one. E.g.
-
-```
-1 = 0 + 1
-2 = 0 + 1 + 1
-3 = 0 + 1 + 1 + 1
-etc.
-```
-
-### 2.3.3 Operator `-`
-
-Integer subtraction. Take an integer and remove another integer from it.
-
-### 2.3.4 Operator `*`
-
-Integer multiplication. Init result to zero, add an integer `a` and
-repeat `b` times.
-
-### 2.3.5 Operator `/`
-
-Integer division. The inverse of multiplication :
-for all integers `a` and `b` there is a couple `q` and `r` that satisfies
-`a = b * q + r`. Integer division returns `q`.
-
-### 2.3.6 Operator `mod`
-
-Integer modulo. Returns `r` in the previous equation (see Operator `/`)
-
-### 2.3.7 Operator `<<`
-
-Left shift
-
-
-## 2.4 Examples
-
-```
-ikc3> type(1)
-U8
-ikc3> type(1000000000000000000000000000000)
-Integer
-ikc3> a = 1 + 100000000000000000000000000000000
-100000000000000000000000000000001
-ikc3> a * a
-10000000000000000000000000000000200000000000000000000000000000001
-ikc3> a * a / 1000000000000000000000000000000000000000000000000000
-10000000000000
-```
diff --git a/doc/1 KC3/1.3 Map.en.md b/doc/1 KC3/1.3 Map.en.md
deleted file mode 100644
index 27cc576..0000000
--- a/doc/1 KC3/1.3 Map.en.md
+++ /dev/null
@@ -1,42 +0,0 @@
-# 3 Map
-
-KC3 maps are like Elixir maps, they are key-values enclosed in `%{}` :
-
-```
-ikc3> a = %{id: 1, title: "My title", message: "Hello, world !"}
-%{id: 1, title: "My title", message: "Hello, world !"}
-```
-
-Destructuring works with maps to extract values :
-
-```
-ikc3> %{id: id, title: "My title", message: message} = ^ a
-%{id: 1, title: "My title", message: "Hello, world !"}
-ikc3> id
-1
-ikc3> message
-"Hello, world !"
-```
-
-
-You can use the dot syntax to access map values from a `Sym` key :
-
-```
-ikc3> a = %{id: 1, title: "My title", message: "Hello, world !"}
-%{id: 1, title: "My title", message: "Hello, world !"}
-ikc3> a.id
-1
-ikc3> a.message
-"Hello, world !"
-```
-
-You can also use the `KC3.access` function for the same result :
-
-```
-ikc3> a = %{id: 1, title: "My title", message: "Hello, world !"}
-%{id: 1, title: "My title", message: "Hello, world !"}
-ikc3> access(a, :id)
-1
-ikc3> access(a, :message)
-"Hello, world !"
-```
diff --git a/doc/1 KC3/1.4 Ratio.en.md b/doc/1 KC3/1.4 Ratio.en.md
deleted file mode 100644
index 0b889ce..0000000
--- a/doc/1 KC3/1.4 Ratio.en.md
+++ /dev/null
@@ -1,17 +0,0 @@
-# 4 Ratio
-
-Ratios are made with a couple of large integers : the numerator
-which can be any number, and the denominator which has to be positive.
-They represent fractions of integral numbers.
-They are written with a slash and no space.
-
-```
-ikc3> 1/2 + 2/3
-7/6
-ikc3> 1/2 * 2/3
-1/3
-ikc3> 1/2 / 2/3
-3/4
-ikc3> 1/2 - 2/3
--1/6
-```
diff --git a/doc/1 KC3/1.5 List.en.md b/doc/1 KC3/1.5 List.en.md
deleted file mode 100644
index 259d1b1..0000000
--- a/doc/1 KC3/1.5 List.en.md
+++ /dev/null
@@ -1,30 +0,0 @@
-# 5 List
-
-Linked lists owning the data (each node contains a couple of tags :
-one for data and one for next pointer.
-
-Regular lists can be :
- - multiple elements : `[1, 2, 3]`
- - an element and a list : `[1 | [2, 3]]`
- - multiple elements and a list : `[1, 2 | [3]]`
- - the empty list : `[]`
-
-Regular lists end with the empty list : `[1] == [1 | []]`.
-
-You can also contruct dotted lists like in Common Lisp where
-the next list pointer is an arbitrary form. E.g. :
- - an element and an element : `[1 | 2]`
- - multiple elements and an element : `[1, 2, 3 | 4]`
- - the empty list and an element : `[[] | 1]`
-
-All these list formats are supported in pattern matching.
-
-## 5.1 Functions
-
-```
-List List.map (List, Fn)
-```
-
-```
-List List.reverse (List)
-```
diff --git a/doc/1 KC3/1.6 Variable.en.md b/doc/1 KC3/1.6 Variable.en.md
deleted file mode 100644
index 7c38729..0000000
--- a/doc/1 KC3/1.6 Variable.en.md
+++ /dev/null
@@ -1,50 +0,0 @@
-# 6 Variables
-
-Variables in KC3 can be defined using the litteral value for a variable
-which is always `?`. You can cast this litteral value and it will not
-really be casted but it will give you a typed variable litteral value.
-E.g. `(List) ?`.
-The typed variable litteral value will only accept to be set once to
-one value of the variable's type (in this example the type of a linked
-list).
-
-It's actually a syntax so you cannot rename `?` by mistake and
-so is an easy task to do static analysis of variable creation.
-
-The default type for a variable which you can also specify explicitly
-is `Tag` which is an enum-tagged union type of any other KC3 types
-currently defined in the environment. So `?` is exactly equivalent to
-`(Tag) ?` and they will both accept to be set once to one value of any
-type.
-
-A variable is settable once and cannot be changed afterwards (there is
-an exception if you write C code and link to it but it is not easy nor
-silent).
-
-This way you do not need to lock or trust any behaviour, once your
-variable is set to a value the value of the variable will never change,
-it really is read-only.
-
-You can also use the assignment operator which is `<-` which in turn calls
-`tag_init_copy`. It works like the C assignment operator (`=`).
-
-Examples :
-```
-# Declare a unsigned byte 8 bits variable "x".
-x = (U8) ?
-# Set the variable "x" to zero.
-x <- 0
-# Allocate again for the same binding name "x"
-x = (U8) ?
-# Also set the new variable "x" to zero with just one Unicode symbol
-# that is AltGr+Y on my keyboard.
-x ← 0
-```
-
-
-## So how do I change anything if it is read-only ?
-
-You can always reset an existing binding at will to another variable
-litteral and another variable will be created for the same name and it
-will be in a different memory location, settable once and then
-read-only again so you can use it without locking.
diff --git a/doc/1 KC3/index.en.html b/doc/1 KC3/index.en.html
deleted file mode 100644
index e08dff1..0000000
--- a/doc/1 KC3/index.en.html
+++ /dev/null
@@ -1,46 +0,0 @@
-<div>
-  <div class="KC3-1">
-    <div>
-      <p>
-        <b>KC3</b> is a programming language with meta-programmation
-        and a graph database embedded into the language.
-        It aims to be the language for semantic programming,
-        and programming the semantic web.
-      </p>
-      <p>
-        There is a working prototype available at
-        <a target="_blank" href="https://git.kmx.io/kc3-lang/kc3/">https://git.kmx.io/kc3-lang/kc3/</a>.
-      </p>
-      <p>
-        Please see the
-        <a target="_blank" href="https://www.kmx.io/en/donations.html">https://www.kmx.io/en/donations.html</a>
-        page if you want to help out.
-      </p>
-      <p>KC3 is currently a programming language project, inspired by C,
-        Elixir and Common Lisp. It could be described as C with Elixir
-        modules, pattern matching, and a semantic object system. The
-        idea is to plug modules, closures, pattern matching, a graph
-        database and metaprogramming into C99 with an extremely small
-        set of dependencies.
-      </p>
-      <p>
-        Supported operating systems (additionnal dependencies) :
-        <ul>
-          <li>BSD</li>
-          <li>Linux (libbsd, libmd)</li>
-          <li>MacOS X (libmd)</li>
-          <li>Windows (MSys2)</li>
-        </ul>
-      </p>
-      <p>
-        Supported architectures :
-        <ul>
-          <li>aarch64 (arm64, Apple M1, Apple M2)</li>
-          <li>amd64</li>
-          <li>i386</li>
-          <li>sparc64</li>
-        </ul>
-      </p>
-    </div>
-  </div>
-</div>
diff --git a/doc/1_KC3/1.1_Introduction.en.md b/doc/1_KC3/1.1_Introduction.en.md
new file mode 100644
index 0000000..00e45ab
--- /dev/null
+++ b/doc/1_KC3/1.1_Introduction.en.md
@@ -0,0 +1,65 @@
+# 1 Introduction
+
+KC3 is currently a programming language project, inspired by C, Elixir
+and Common Lisp. It could be described as C with Elixir modules,
+pattern matching, and a semantic object system. The idea is to plug
+modules, closures, pattern matching, a graph database and
+metaprogramming into C99 with an extremely small set of dependencies.
+
+Supported operating systems (additionnal dependencies) :
+ - BSD
+ - Linux (libbsd, libmd)
+ - MacOS X (libmd)
+ - Windows (MSys2)
+
+Supported architectures :
+ - aarch64 (arm64, Apple M1, Apple M2)
+ - amd64
+ - i386
+ - sparc64
+
+
+## 1.1 Modules
+
+Everything in KC3 is in a module. A module is a namespace,
+and is named with a symbol starting with a uppercase character.
+For instance `Sym` and `Str` are valid module names.
+
+Each module can define a type and a module name can also be a
+type name if the corresponding module defines a type.
+
+The module can also include definitions for functions for
+operating on the module type or other types.
+
+The default module is `KC3`, which is defined as facts (triples)
+in `lib/kc3/0.1/kc3.facts`.
+
+
+## 1.2 Data types
+
+Basic data types in KC3 are :
+ - Strings : `Str`, e.g. `"Hello, world !"`
+ - Symbols : `Sym`, e.g. `:hello` or `Hello`
+ - Booleans : `Bool`, `true` or `false`
+ - Numbers
+   - Integers
+     - Small integers
+       - Signed small integers : `S8`, `S16`, `S32`, `S64`, `Sw`
+       - Unsigned small integers : `U8`, `U16`, `U32`, `U64`, `Uw`
+     - Large integers : `Integer`
+   - Rational numbers (fractions of integers) : `Ratio`, e.g. `-2/3`
+   - Floating point numbers : `F32`, `F64`, `F128`
+   - Complex numbers (i = √(-1)) : `Complex`, e.g. `1 +i 2`
+ - Lists : `List`, e.g. `[1, 2, 3]`
+ - Tuples : `Tuple`, e.g. `{:ok, 123}`
+ - Maps : `Map`, e.g. `%{id: 1, login: "dx"}`
+ - Structs : e.g. `%GL.Sphere{}`
+ - Quoted code : `Quote`, e.g. `quote 1 + 2`
+ - Identifiers : `Ident`, e.g. `quote hello`
+ - Function or operator call : `Call`, e.g. `quote sqrt(1)`, `quote 1 + 2`
+ - Code blocks : `Block`, e.g. `{ 1 + 2; 3 + 4 }`
+ - Function : `Fn`, e.g. `fn (x) { x * 2 }`
+ - C function : `Cfn`, e.g. `cfn Tag "tag_add" (Tag, Tag, Result)`
+ - Unquoted code: `Unquote`, e.g. `quote 1 + unquote(x)`
+ - Variables : `Var`, e.g. `?`
+ - Void : `Void`, e.g. `void`
diff --git a/doc/1_KC3/1.2_Integer.en.md b/doc/1_KC3/1.2_Integer.en.md
new file mode 100644
index 0000000..4b6b2b4
--- /dev/null
+++ b/doc/1_KC3/1.2_Integer.en.md
@@ -0,0 +1,128 @@
+# 2 Integers
+
+## 2.1 Small integers
+
+IKC3 supports all C integer type sizes from `U8` (matching the C type `uint8_t`)
+to `U64` (matching the C type `uint64_t`) for unsigned integers,
+and from `S8` to `S64` for signed integers.
+
+In addition to these 8 basic integer types there are 2 pointer-sized
+integer types :
+`Uw` for unsigned pointer-sized integers,
+and `Sw` for signed pointer-sized integers.
+
+Small integers take little space, are static, they are passed directly and
+not as a pointer, and for these reasons are fast.
+
+They do not need to be cleaned after use and thus can be used in arrays like
+is usually done in C.
+
+```
+ikc3> type(-1)
+S8
+ikc3> type(-128)
+S16
+ikc3> type(-32768)
+S32
+ikc3> type(-2147483648)
+S64
+ikc3> type(-9223372036854775807)
+S64
+ikc3> type(0)
+U8
+ikc3> type(256)
+U16
+ikc3> type(65536)
+U32
+ikc3> type(4294967296)
+U64
+ikc3> type(18446744073709551615)
+U64
+```
+
+## 2.2 Large integers
+
+IKC3 supports large integers and they are compatible with small integers.
+Their type is `Integer` and can support numbers as large as memory allows.
+They are slow because they are allocated dynamically on the heap
+using malloc.
+
+```
+ikc3> type(1000000000000000000000000000000)
+Integer
+```
+
+
+## 2.3 Operations on integers
+
+### 2.3.1 Operator `~`
+
+Binary not.
+
+```
+ikc3> ~ 1
+254
+ikc3> ~ -1
+0
+ikc3> ~ 0
+255
+ikc3> ~ 255
+0
+ikc3> ~ (U16) 1
+65534
+ikc3> ~ (S16) 1
+-2
+```
+
+### 2.3.2 Operator `+`
+
+Integer addition.
+
+All positive integers can be defined in terms of addition of :
+zero or a positive integer, and one. E.g.
+
+```
+1 = 0 + 1
+2 = 0 + 1 + 1
+3 = 0 + 1 + 1 + 1
+etc.
+```
+
+### 2.3.3 Operator `-`
+
+Integer subtraction. Take an integer and remove another integer from it.
+
+### 2.3.4 Operator `*`
+
+Integer multiplication. Init result to zero, add an integer `a` and
+repeat `b` times.
+
+### 2.3.5 Operator `/`
+
+Integer division. The inverse of multiplication :
+for all integers `a` and `b` there is a couple `q` and `r` that satisfies
+`a = b * q + r`. Integer division returns `q`.
+
+### 2.3.6 Operator `mod`
+
+Integer modulo. Returns `r` in the previous equation (see Operator `/`)
+
+### 2.3.7 Operator `<<`
+
+Left shift
+
+
+## 2.4 Examples
+
+```
+ikc3> type(1)
+U8
+ikc3> type(1000000000000000000000000000000)
+Integer
+ikc3> a = 1 + 100000000000000000000000000000000
+100000000000000000000000000000001
+ikc3> a * a
+10000000000000000000000000000000200000000000000000000000000000001
+ikc3> a * a / 1000000000000000000000000000000000000000000000000000
+10000000000000
+```
diff --git a/doc/1_KC3/1.3_Map.en.md b/doc/1_KC3/1.3_Map.en.md
new file mode 100644
index 0000000..27cc576
--- /dev/null
+++ b/doc/1_KC3/1.3_Map.en.md
@@ -0,0 +1,42 @@
+# 3 Map
+
+KC3 maps are like Elixir maps, they are key-values enclosed in `%{}` :
+
+```
+ikc3> a = %{id: 1, title: "My title", message: "Hello, world !"}
+%{id: 1, title: "My title", message: "Hello, world !"}
+```
+
+Destructuring works with maps to extract values :
+
+```
+ikc3> %{id: id, title: "My title", message: message} = ^ a
+%{id: 1, title: "My title", message: "Hello, world !"}
+ikc3> id
+1
+ikc3> message
+"Hello, world !"
+```
+
+
+You can use the dot syntax to access map values from a `Sym` key :
+
+```
+ikc3> a = %{id: 1, title: "My title", message: "Hello, world !"}
+%{id: 1, title: "My title", message: "Hello, world !"}
+ikc3> a.id
+1
+ikc3> a.message
+"Hello, world !"
+```
+
+You can also use the `KC3.access` function for the same result :
+
+```
+ikc3> a = %{id: 1, title: "My title", message: "Hello, world !"}
+%{id: 1, title: "My title", message: "Hello, world !"}
+ikc3> access(a, :id)
+1
+ikc3> access(a, :message)
+"Hello, world !"
+```
diff --git a/doc/1_KC3/1.4_Ratio.en.md b/doc/1_KC3/1.4_Ratio.en.md
new file mode 100644
index 0000000..0b889ce
--- /dev/null
+++ b/doc/1_KC3/1.4_Ratio.en.md
@@ -0,0 +1,17 @@
+# 4 Ratio
+
+Ratios are made with a couple of large integers : the numerator
+which can be any number, and the denominator which has to be positive.
+They represent fractions of integral numbers.
+They are written with a slash and no space.
+
+```
+ikc3> 1/2 + 2/3
+7/6
+ikc3> 1/2 * 2/3
+1/3
+ikc3> 1/2 / 2/3
+3/4
+ikc3> 1/2 - 2/3
+-1/6
+```
diff --git a/doc/1_KC3/1.5_List.en.md b/doc/1_KC3/1.5_List.en.md
new file mode 100644
index 0000000..259d1b1
--- /dev/null
+++ b/doc/1_KC3/1.5_List.en.md
@@ -0,0 +1,30 @@
+# 5 List
+
+Linked lists owning the data (each node contains a couple of tags :
+one for data and one for next pointer.
+
+Regular lists can be :
+ - multiple elements : `[1, 2, 3]`
+ - an element and a list : `[1 | [2, 3]]`
+ - multiple elements and a list : `[1, 2 | [3]]`
+ - the empty list : `[]`
+
+Regular lists end with the empty list : `[1] == [1 | []]`.
+
+You can also contruct dotted lists like in Common Lisp where
+the next list pointer is an arbitrary form. E.g. :
+ - an element and an element : `[1 | 2]`
+ - multiple elements and an element : `[1, 2, 3 | 4]`
+ - the empty list and an element : `[[] | 1]`
+
+All these list formats are supported in pattern matching.
+
+## 5.1 Functions
+
+```
+List List.map (List, Fn)
+```
+
+```
+List List.reverse (List)
+```
diff --git a/doc/1_KC3/1.6_Variable.en.md b/doc/1_KC3/1.6_Variable.en.md
new file mode 100644
index 0000000..7c38729
--- /dev/null
+++ b/doc/1_KC3/1.6_Variable.en.md
@@ -0,0 +1,50 @@
+# 6 Variables
+
+Variables in KC3 can be defined using the litteral value for a variable
+which is always `?`. You can cast this litteral value and it will not
+really be casted but it will give you a typed variable litteral value.
+E.g. `(List) ?`.
+The typed variable litteral value will only accept to be set once to
+one value of the variable's type (in this example the type of a linked
+list).
+
+It's actually a syntax so you cannot rename `?` by mistake and
+so is an easy task to do static analysis of variable creation.
+
+The default type for a variable which you can also specify explicitly
+is `Tag` which is an enum-tagged union type of any other KC3 types
+currently defined in the environment. So `?` is exactly equivalent to
+`(Tag) ?` and they will both accept to be set once to one value of any
+type.
+
+A variable is settable once and cannot be changed afterwards (there is
+an exception if you write C code and link to it but it is not easy nor
+silent).
+
+This way you do not need to lock or trust any behaviour, once your
+variable is set to a value the value of the variable will never change,
+it really is read-only.
+
+You can also use the assignment operator which is `<-` which in turn calls
+`tag_init_copy`. It works like the C assignment operator (`=`).
+
+Examples :
+```
+# Declare a unsigned byte 8 bits variable "x".
+x = (U8) ?
+# Set the variable "x" to zero.
+x <- 0
+# Allocate again for the same binding name "x"
+x = (U8) ?
+# Also set the new variable "x" to zero with just one Unicode symbol
+# that is AltGr+Y on my keyboard.
+x ← 0
+```
+
+
+## So how do I change anything if it is read-only ?
+
+You can always reset an existing binding at will to another variable
+litteral and another variable will be created for the same name and it
+will be in a different memory location, settable once and then
+read-only again so you can use it without locking.
diff --git a/doc/2 HTTPd/index.en.md b/doc/2 HTTPd/index.en.md
deleted file mode 100644
index 3edfe5b..0000000
--- a/doc/2 HTTPd/index.en.md
+++ /dev/null
@@ -1,55 +0,0 @@
-# 2 KC3 HTTPd web server
-
-The source files for the KC3 HTTPd web server are in `/httpd`.
-
-## 2.1 Dependencies
-
-The web server depends on :
- - KC3
-   - libkc3
-   - event
-   - socket
-   - http
- - [SASS](https://sass-lang.com/) for CSS rendering
- - [ESBuild](https://esbuild.github.io/) for Javascript rendering
-
-## 2.2 Configuration
-
-The web server must be started in a directory containing the following
-files :
-
-```
-./app/controllers/     # controllers directory (.kc3)
-./app/templates/       # templates directory (.ekc3)
-./app/views/           # views directory (.kc3)
-./assets/              # assets directory
-./assets/css/          # css directory
-./assets/css/app.scss  # application css, compiled to ./static/_assets/app.css
-./assets/js/           # javascript directory
-./assets/js/app.js     # application javascript, compiled to ./static/_assets/app.js
-./assets/node_modules/ # from npm
-./config/routes.kc3    # dynamic routes
-./static/              # for static files
-./static/_assets/      # for static asset files
-./static/_fonts/       # for static font files
-./static/_images/      # for static image files
-```
-
-## 2.3 Example
-
-Run `make test_httpd` to run the KC3 HTTPd web server (`httpd/kc3_httpd`)
-starting in the `test/httpd` working directory.
-
-This directory contains an example of configuring and using `kc3_httpd`.
-
-Static files are served from ./static and is mapped to root URL (`/`).
-
-Documentation in Markdown and HTML format is served from the `/doc/` URL.
-The documentation has a custom route defined in `./config/routes.kc3`,
-a controller defined in `./app/controllers/doc_controller.kc3` and
-a few templates defined in `./app/templates/doc/`.
-
-The main layout for the application is stated in
-`./app/templates/layout.html.ekc3` and `./app/templates/nav.html.ekc3`.
-Notice the `.html.ekc3` extension, these are HTML files with embedded KC3.
-See the [EKC3](/doc/EKC3) documentation for more information on these files.
diff --git a/doc/2_HTTPd/index.en.md b/doc/2_HTTPd/index.en.md
new file mode 100644
index 0000000..3edfe5b
--- /dev/null
+++ b/doc/2_HTTPd/index.en.md
@@ -0,0 +1,55 @@
+# 2 KC3 HTTPd web server
+
+The source files for the KC3 HTTPd web server are in `/httpd`.
+
+## 2.1 Dependencies
+
+The web server depends on :
+ - KC3
+   - libkc3
+   - event
+   - socket
+   - http
+ - [SASS](https://sass-lang.com/) for CSS rendering
+ - [ESBuild](https://esbuild.github.io/) for Javascript rendering
+
+## 2.2 Configuration
+
+The web server must be started in a directory containing the following
+files :
+
+```
+./app/controllers/     # controllers directory (.kc3)
+./app/templates/       # templates directory (.ekc3)
+./app/views/           # views directory (.kc3)
+./assets/              # assets directory
+./assets/css/          # css directory
+./assets/css/app.scss  # application css, compiled to ./static/_assets/app.css
+./assets/js/           # javascript directory
+./assets/js/app.js     # application javascript, compiled to ./static/_assets/app.js
+./assets/node_modules/ # from npm
+./config/routes.kc3    # dynamic routes
+./static/              # for static files
+./static/_assets/      # for static asset files
+./static/_fonts/       # for static font files
+./static/_images/      # for static image files
+```
+
+## 2.3 Example
+
+Run `make test_httpd` to run the KC3 HTTPd web server (`httpd/kc3_httpd`)
+starting in the `test/httpd` working directory.
+
+This directory contains an example of configuring and using `kc3_httpd`.
+
+Static files are served from ./static and is mapped to root URL (`/`).
+
+Documentation in Markdown and HTML format is served from the `/doc/` URL.
+The documentation has a custom route defined in `./config/routes.kc3`,
+a controller defined in `./app/controllers/doc_controller.kc3` and
+a few templates defined in `./app/templates/doc/`.
+
+The main layout for the application is stated in
+`./app/templates/layout.html.ekc3` and `./app/templates/nav.html.ekc3`.
+Notice the `.html.ekc3` extension, these are HTML files with embedded KC3.
+See the [EKC3](/doc/EKC3) documentation for more information on these files.
diff --git a/lib/kc3/0.1/str.facts b/lib/kc3/0.1/str.facts
index 755bc8d..404d311 100644
--- a/lib/kc3/0.1/str.facts
+++ b/lib/kc3/0.1/str.facts
@@ -23,3 +23,6 @@ replace {Str.starts_with?, :symbol_value,
 add {Str, :symbol, Str.has_str?}
 replace {Str.has_str?, :symbol_value,
          cfn Bool "str_has_str" (Str, Str, Result)}
+add {Str, :symbol, Str.subst}
+replace {Str.subst, :symbol_value,
+         cfn Str "str_init_subst" (Result, Str, Str, Str)}
diff --git a/libkc3/str.c b/libkc3/str.c
index 755251f..9606d9e 100644
--- a/libkc3/str.c
+++ b/libkc3/str.c
@@ -592,6 +592,67 @@ s_str * str_init_slice (s_str *str, const s_str *src, sw start, sw end)
   return str;
 }
 
+s_str * str_init_subst (s_str *str, const s_str *src,
+                        const s_str *search, const s_str *replace)
+{
+  character c;
+  s_buf in;
+  s_buf out;
+  sw r;
+  sw size;
+  assert(str);
+  assert(src);
+  assert(search);
+  assert(replace);
+  if ((size = str_init_subst_size(src, search, replace)) < 0)
+    return NULL;
+  if (! buf_init_alloc(&out, size))
+    return NULL;
+  buf_init_str_const(&in, src);
+  while (in.wpos - in.rpos >= search->size) {
+    if (buf_read_str(&in, search) > 0) {
+      if ((r = buf_write_str(&out, replace)) < 0)
+        goto clean;
+    }
+    else {
+      if ((r = buf_read_character_utf8(&in, &c)) < 0)
+        break;
+      if ((r = buf_write_character_utf8(&out, c)) < 0)
+        goto clean;
+    }
+  }
+  if ((r = buf_xfer(&out, &in, in.wpos - in.rpos)) < 0)
+    goto clean;
+  buf_to_str(&out, str);
+  return str;
+ clean:
+  buf_clean(&out);
+  return NULL;
+}
+
+sw str_init_subst_size (const s_str *src, const s_str *search,
+                        const s_str *replace)
+{
+  character c;
+  s_buf in;
+  sw r;
+  sw result = 0;
+  assert(src);
+  assert(search);
+  assert(replace);
+  buf_init_str_const(&in, src);
+  while (in.wpos - in.rpos >= search->size) {
+    if (buf_read_str(&in, search) > 0)
+      result += replace->size;
+    else {
+      if ((r = buf_read_character_utf8(&in, &c)) < 0)
+        return -1;
+      result += r;
+    }
+  }
+  return result;
+}
+
 s_str * str_init_to_lower (s_str *str, const s_str *src)
 {
   s_buf buf;
diff --git a/libkc3/str.h b/libkc3/str.h
index 1b9b7b8..2b7e707 100644
--- a/libkc3/str.h
+++ b/libkc3/str.h
@@ -66,6 +66,10 @@ PROTOTYPE_STR_INIT_INT(s64);
 s_str * str_init_slice (s_str *str, const s_str *src, sw start, sw end);
 s_str * str_init_slice_utf8 (s_str *str, const s_str *src, sw start,
                              sw end);
+s_str * str_init_subst (s_str *str, const s_str *src,
+                        const s_str *search, const s_str *replace);
+sw      str_init_subst_size (const s_str *src, const s_str *search,
+                             const s_str *replace);
 PROTOTYPE_STR_INIT_STRUCT(struct);
 PROTOTYPE_STR_INIT_INT(sw);
 s_str * str_init_to_lower (s_str *str, const s_str *src);
diff --git a/test/httpd/app/controllers/doc_controller.kc3 b/test/httpd/app/controllers/doc_controller.kc3
index 1d8e589..8d6ed32 100644
--- a/test/httpd/app/controllers/doc_controller.kc3
+++ b/test/httpd/app/controllers/doc_controller.kc3
@@ -17,7 +17,7 @@ defmodule DocController do
         doc_index(rest, path_md, dir, acc)
       else
         path = dir + file
-        name = ^ file
+        name = Str.subst(file, "_", " ")
         url = Str.slice(path, 1, -1)
         if File.is_directory?(path) do
           items = doc_index(List.sort(File.list(path)), path_md,
@@ -54,7 +54,7 @@ defmodule DocController do
     }
     (path, path_md, dir, acc) {
       if (type(path) == Str) do
-        doc_index(File.list(path), path_md, dir, acc)
+        doc_index(List.sort(File.list(path)), path_md, dir, acc)
       end
     }
   }