aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Veresov <aleksey@veresov.pro>2021-01-04 17:43:58 +0300
committerAleksey Veresov <aleksey@veresov.pro>2021-01-04 17:43:58 +0300
commite96facabd92d3eb61a4f97dfc3436a34dae4812d (patch)
treedd8a027de2a61c005b08cde06bc682895aa71ddf
parentfa6a4104b04aa7834fdafc3aca9b479605445ca7 (diff)
downloadcsx-e96facabd92d3eb61a4f97dfc3436a34dae4812d.tar
csx-e96facabd92d3eb61a4f97dfc3436a34dae4812d.tar.xz
csx-e96facabd92d3eb61a4f97dfc3436a34dae4812d.zip
Example improved.
-rw-r--r--examples/generated.csx30
-rw-r--r--src/csx.c3
2 files changed, 24 insertions, 9 deletions
diff --git a/examples/generated.csx b/examples/generated.csx
index 8710bd6..4c405c4 100644
--- a/examples/generated.csx
+++ b/examples/generated.csx
@@ -12,17 +12,29 @@
[set map [fn [f l] [if [no l] []
[pair [f [head l]] [map f [tail l]]]
]]]
-[map [fn [n] [outint n] [out 10]]
- [quote [99 37 73 42]]
-]
[set id [fn args args]]
-[outint [[id 42 13 31] 2]]
-[out 10]
-[out ["Hello!" 1]]
-[out 10]
[set outstr [fn [str] [if str
[do [out [head str]] [outstr [tail str]]]
[]
]]]
-[outstr "Hello, World!"]
-[out 10]
+[set newline [fn [] [out 10]]]
+[set instr [fn []
+ [set c [in]]
+ [if [same c 10]
+ []
+ [pair c [instr]]
+ ]
+]]
+
+[outstr "-= loaded =-"]
+[newline]
+[outstr "Hello, I am Conrad S. Xylander. What is your name?"]
+[newline]
+[outstr "> "]
+[set name [instr]]
+[outstr "Nice to meet you, "]
+[outstr name]
+[outstr "."]
+[newline]
+[outstr "I have to go. Goodbye!"]
+[newline]
diff --git a/src/csx.c b/src/csx.c
index bacf0f7..c265631 100644
--- a/src/csx.c
+++ b/src/csx.c
@@ -97,6 +97,7 @@ int *csx_int(int num)
}
int *res = new(type_int, sizeof(int));
*res = num;
+ ints = new_pair(res, ints);
return res;
}
@@ -441,6 +442,8 @@ static void new_context()
static void init()
{
initiated = 1;
+ setbuf(stdin, 0);
+ setbuf(stdout, 0);
null = new(type_null, 0);
names = null;
ints = null;