aboutsummaryrefslogtreecommitdiff
path: root/examples/generated.csx
diff options
context:
space:
mode:
authorAleksey Veresov <aleksey@veresov.pro>2021-01-05 22:16:50 +0300
committerAleksey Veresov <aleksey@veresov.pro>2021-01-05 22:16:50 +0300
commit1afd0cdc7820d9c3a9ae032ea40545d7d32bf9bf (patch)
tree949ee5d2423088fcda8fc958e31e36f8de727d92 /examples/generated.csx
parent5d7eed48337ff1f9a30118f5d8be67c641bbfcf8 (diff)
downloadcsx-1afd0cdc7820d9c3a9ae032ea40545d7d32bf9bf.tar
csx-1afd0cdc7820d9c3a9ae032ea40545d7d32bf9bf.tar.xz
csx-1afd0cdc7820d9c3a9ae032ea40545d7d32bf9bf.zip
String type added.
Diffstat (limited to 'examples/generated.csx')
-rw-r--r--examples/generated.csx100
1 files changed, 60 insertions, 40 deletions
diff --git a/examples/generated.csx b/examples/generated.csx
index 14943b2..62fd2eb 100644
--- a/examples/generated.csx
+++ b/examples/generated.csx
@@ -1,47 +1,67 @@
+{ Base Utilities }
+
[set no [fn [x] [same x []]]]
-[set outint [fn [n] [if [< n 0]
- [do [out 45] [outint [neg n]]]
- [if [< n 10]
- [out [+ 48 n]]
- [do
- [outint [div n 10]]
- [out [+ 48 [mod n 10]]]
+[set id [fn [arg] arg]]
+[set list [fn args args]]
+
+[set catrev [fn [a b] [if a [catrev [tail a] [pair [head a] b]] b]]]
+[set rev [fn [l] [catrev l []]]]
+[set cat [fn [a b] [catrev [rev a] b]]]
+
+[set map [fn [f l] [if l [pair [f [head l]] [map f [tail l]]]]]]
+[set reduce [fn [f l] [if [no l] [] [if [no [tail l]] [head l]
+ [f [head l] [reduce f [tail l]]]
+]]]]
+
+[set - [fn =[a rest] [+ a [reduce + [map neg rest]]]]]
+
+
+{ Input-Output }
+
+[set newline [str [list 10]]]
+
+[set outint [fn [n]
+ [set zero 48]
+ [set minus 45]
+ [if [< n 0]
+ [do [out minus] [outint [neg n]]]
+ [if [< n 10]
+ [out [+ zero n]]
+ [do
+ [outint [div n 10]]
+ [out [+ zero [mod n 10]]]
+ ]
]
]
-]]]
-[set map [fn [f l] [if l [pair [f [head l]] [map f [tail l]]]]]]
-[set id [fn args args]]
-[set outstr [fn [str] [if str [do [out [head str]] [outstr [tail str]]]]]]
-[set newline [fn [] [out 10]]]
-[set instr [fn []
- [set c [in]]
- [if [no [same c 10]] [pair c [instr]]]
]]
-[set outints [fn [l]
- [set outcontent [fn [l]
- [if l [do [outint [head l]] [out 32] [outcontent [tail l]]]]
+
+[set outstr [fn [str]
+ [set outstrat [fn [str i len] [if [no [same i len]] [do
+ [out [str i]]
+ [outstrat str [+ i 1] len]
+ ]]]]
+ [outstrat str 0 [len str]]
+]]
+
+[set output [fn objs [map [fn [obj] [if
+ [same [type obj] 'int] [outint obj]
+ [same [type obj] 'str] [outstr obj]
+]] objs]]]
+
+[set instr [fn []
+ [set instract [fn []
+ [set c [in]]
+ [if [no [same c 10]] [pair c [instract]]]
]]
- [out 91] [outcontent l] [out 93]
+ [str [instract]]
]]
-[set rappend [fn [a b] [if a [rappend [tail a] [pair [head a] b]] b]]]
-[set rev [fn [l] [rappend l []]]]
-[set append [fn [a b] [rappend [rev a] b]]]
-[set backwards [sx body [pair 'do [rev body]]]]
-
-[outstr "-= loaded =-"]
-[newline]
-[outstr "Hello, I am Casey Shawn Exton. What is your name?"]
-[newline]
-[outstr "> "]
+
+
+{ The Program }
+
+[output "Hello, I am Casey Shawn Exton. " "What is your name?" newline]
+[output "> "]
[set name [instr]]
-[outstr "Nice to meet you, "]
-[outstr name]
-[outstr "."]
-[newline]
-[outstr "I have to go. Goodbye!"]
-[newline]
-
-[backwards
- [outstr magic]
- [set magic [rev "magic"]]
-]
+[output "Nice to meet you, " name "." newline]
+[output "Your name is " [len name] " characters long." newline]
+[output "I have to go. Goodbye!" newline]