Commit eeed32052a845804a1ea8baca3c279d583b70461

Thomas de Grivel 2024-02-15T11:59:48

wip if

diff --git a/.ic3_history b/.ic3_history
index dde0cba..753f3d6 100644
--- a/.ic3_history
+++ b/.ic3_history
@@ -1,47 +1,3 @@
-"ab" + "cd"
-"ab" + "cd" + "ef"
-"Bonjour " + name + " !"
-hello = fn (name) { "Hello, " + name + " !" }
-hello("Patrice")
-hello("Thomas")
-"Hello, " + "Tiyon" + " !"
-hello = fn (name) { "Hello, " + name + " !" }
-hello("Tiyon")
-hello("Patrice")
-"Hello, #{name} !"
-hello("Tiyon")
-hello = fn (name) { "Hello, " + name + " !" }
-hello("Tiyon")
-hello("Baptiste")
-"a"
-"abc"
-hello = fn (name) { "Hello, #{name} !" }
-hello("Thomas")
-hello = fn (name) { "Hello, #{name} !" }
-name("Thomas")
-hello("Thomas")
-hello = fn (name) { "Hello, #{name} !" }
-hello("Paul")
-quote hello("Paul")
-hello
-quote unquote 1
-quote quote unquote 1
-quote unquote 1
-quote quote unquote 1
-dlopen("libc3/window/.libs/libc3_window_debug.so.0.0")
-dlopen("libc3/window/sdl2/.libs/libc3_window_sdl2_debug.so.0.0")
-dlopen("libc3/window/.libs/libc3_window_debug.so.0.0")
-dlopen("libc3/window/.libs/libc3_window.so.0.0")
-dlopen("../libc3/window/.libs/libc3_window_debug.so.0.0")
-dlopen("../libc3/window/sdl2/.libs/libc3_window_sdl2_debug.so.0.0")
-dlopen("../libc3/window/.libs/libc3_window_debug.so.0.0")
-dlopen("../libc3/window/sdl2/.libs/libc3_window_sdl2_debug.so.0.0")
-%GL.Object{}
-type(%GL.Object{})
-%GL.Object{}
-dlopen("../libc3/window/.libs/libc3_window_debug.so.0.0")
-dlopen("../libc3/window/sdl2/.libs/libc3_window_sdl2_debug.so.0.0")
-%GL.Object{}
 quote %GL.Object{}
 quote %GL.Sphere{}
 dlopen("../libc3/window/.libs/libc3_window_debug.so.0.0")
@@ -97,3 +53,48 @@ m = macro (name) { quote "Hello, " + name + " !" }
 m("123")
 m = macro (name) { quote "Hello, " + name + " !" }
 m("123")
+if(true, 1, 2)
+if(false, 1, 2)
+if(false, 1 + 1, 2 + 2)
+if(true, 1 + 1, 2 + 2)
+1 + 1
+1 + 100000000000000000000000000000000000000
+hello = fn (name) { "Hello, #{name} !" }
+hello("Guillaume")
+m = macro (name) { quote "Hello, " + name + " !" }
+m("123")
+if(true, 1, 2)
+
+%{name: "Guillaume", food: "sushis"}
+user = %{name: "Guillaume", food: "sushis"}
+greet = fn (%{name: n, food: f}) do
+  "Hello, #{n}, do you want a #{f} ?"
+end
+u
+user2A
+greet(user)
+greet = fn (%{name: name, food: food}) do
+  "Hello, #{name}, do you want a #{food} ?"
+end
+greet(user)
+g = user
+g = ^ user
+g
+l = %{name: "Labrass", food: "fondue"}
+greet(user)
+greet(l)
+greet(g)
+[g, l]
+List.map(greet, [g, l])
+List.map([g, l], greet)
+List.reverse(List.map([g, l], greet))
+List.reverse([1, 2, 3])
+123 & 123
+123 | 123
+123 bor 123
+123 bor 0
+List.reverse([1, 2, 3])
+dlopen("libc3/window/.libs/libc3_window_debug.so")
+dlopen("libc3/window/sdl2/.libs/libc3_window_sdl2.so")
+%GL.Object{}
+
diff --git a/lib/c3/0.1/c3.facts b/lib/c3/0.1/c3.facts
index 2604539..27a00c4 100644
--- a/lib/c3/0.1/c3.facts
+++ b/lib/c3/0.1/c3.facts
@@ -201,4 +201,4 @@ replace {C3.fib, :fn, fn { (0) { 1 }
                            (x) { fib(x - 1) + fib(x - 2) } }}
 add {C3, :symbol, C3.if}
 replace {C3.if, :is_a, :macro}
-replace {C3.if, :cfn, cfn Tag "c3_if" (Tag, Tag, Tag, Result)
\ No newline at end of file
+replace {C3.if, :cfn, cfn Tag "c3_if" (Tag, Tag, Tag, Result)}
diff --git a/lib/c3/0.1/list.facts b/lib/c3/0.1/list.facts
index c78be55..a2edf02 100644
--- a/lib/c3/0.1/list.facts
+++ b/lib/c3/0.1/list.facts
@@ -6,9 +6,9 @@ add {List, :symbol, List.map}
 add {List, :symbol, List.reverse}
 replace {List.cast, :cfn, cfn List "list_init_cast" (Result, Tag)}
 replace {List.map, :fn, fn {
-  ([], _) {
+  ([], _) do
     []
-  }
+  end
   ([a | b], f) {
     [f(a) | List.map(b, f)]
   }
diff --git a/libc3/c3_main.h b/libc3/c3_main.h
index 0fde3b7..30f010c 100644
--- a/libc3/c3_main.h
+++ b/libc3/c3_main.h
@@ -33,8 +33,8 @@ void c3_clean (s_env *env);
 s_str * c3_getenv (const s_str *name, s_str *dest);
 
 /* Special operators. */
-s_tag * c3_if (const s_tag *cond, const s_tag *then,
-               const s_tag *else_, s_tag *dest);
+s_tag * c3_if (const s_tag *cond, const s_tag *then, const s_tag *else_,
+               s_tag *dest);
 
 /* debug */
 void c3_break (void);