--- /dev/null
+(def D (B B))
+(def T (C I))
+(def V (B C T))
+(def O (S I))
+(def M (S I I))
+(def Q (C B))
+(def L (C B M))
+(def G (B B C))
+(def E (B (B B B)))
+(def R (B B T))
+(def H (B W (B C)))
+(def U (L O))
+(def F (E T T E T))
+
+(def B1 (B B B))
+(def B2 (B B1 B))
+(def B3 (B (B B) B))
+
+(def C* (B C))
+(def C** (B C*))
+(def C*** (B C**))
+
+(def C*n (Z (B (S (C (eq 0) C)) (B D (C B (C - 1))))))
+
+(def C1 (C* (B C)))
+(def C2 (C* (B C1)))
+(def C3 (C* (B C2)))
+
+(def Cn (Z (B (S (C (eq 0) C)) (B (B (B C)) (B D (C B (C - 1)))))))
--- /dev/null
+(def comment (rest (K nil)))
+
+(def map (B (B reverse) (B (B (Z (B (S (S (B (eq nil) (2 cdr)) (B car cdr))) (C B (S (B cons car) (Phi cons (Phi cons (S car (B (B car cdr) cdr)) (B car cdr)) (3 cdr))))))) (C (B B cons) (cons nil)))))
+
+(def list (rest (map unquote)))
+
+(def abstract-rec (B (B (B (C B cons))) (B (B (B B)) (B (B (B Z)) (C (B B (B B (B B (B S (C (C Phi cdr) car))))) (B (B (C B)) (B (C B (C B cdr)) (B (Phi cons) (C (C Phi car) cdr)))))))))
+
+(def abstract-generator (Z (B (B (B (B (C (C C nil))))) (B (Phi B (B S (B cons))) (B (B W) (B (B B)))))))
+
+(def reverse (abstract-rec not (C (B cons car)) cdr nil))
+
+(def len (abstract-rec not (B K (+ 1)) cdr 0))
+
+(def fold (B (S (C (C (eq nil) nil) (Z (B (S (S (B (eq nil) (B cdr cdr)) (B car cdr))) (C B (S (B cons car) (Phi cons (S (S car (B car cdr)) (B car (2 cdr))) (3 cdr)))))))) cons))
+
+(def compose-all (rest (B (fold (B (C B unquote) B)) (cons I))))
+
+(def append (B (C (abstract-rec not (B (C B car) (C cons)) cdr)) reverse))
+
+(def filter (C (C (B (abstract-rec not) (B W (B (B C) (C (B C (B (B B) (C (B B S) (C cons)))) car)))) cdr) nil))
+
+(def qsort ((B Z (B (B (S (W atom))) (Phi (Phi (Phi append)) (B (C B) (C (B (Phi filter) (B (B (B not)) (C B car))) cdr)) (B (B (Phi cons car)) (B (C B) (C (B (Phi filter) (C B car)) cdr))))))))
+
+
+(def import (B (B B) B (map unquote) parse readfile))
+
+
+(import "klsrc/combinators.kl")
+(import "klsrc/util.kl")
\ No newline at end of file
--- /dev/null
+
+(def range (abstract-rec (eq 0) (C cons) (C - 1) nil))
+
+(def x-times-n (C (C (D abstract-rec (eq 0) (D B K cons)) (C - 1)) nil))
+
+(def m-rand-n (B (C (C (D abstract-rec (eq 0) (D B K cons)) (C - 1)) nil) rand))
\ No newline at end of file
.PHONY: web
web: $(WEB_OBJS) $(WEB_BUILD)/../sw.js $(WEB_BUILD)/../setup.js $(WEB_BUILD)/../shell.html $(WEB_BUILD)/../manifest.json
- emcc $(WEB_OBJS) --shell-file $(WEB_SHELL) -o $(WEB_BUILD)/klrepl.html -s NO_EXIT_RUNTIME=1 -s "EXPORTED_RUNTIME_METHODS=['ccall']" --preload-file ../demos.kl@demos.kl
+ mkdir -p $(WEB_BUILD)/../klsources/klsrc/
+ cp -r ../klsrc/*.kl $(WEB_BUILD)/../klsources/klsrc
+ emcc $(WEB_OBJS) --shell-file $(WEB_SHELL) -o $(WEB_BUILD)/klrepl.html -s NO_EXIT_RUNTIME=1 -s "EXPORTED_RUNTIME_METHODS=['ccall']" --preload-file $(WEB_BUILD)/../klsources@/
mkdir -p $(WEB_BUILD)/../static/repl
cp $(WEB_BUILD)/../kl.png $(WEB_BUILD)/../static/repl
cp $(WEB_BUILD)/../manifest.json $(WEB_BUILD)/../static/repl
int main() {
my_env = init_dict();
load_env(my_env);
- load_file(my_env, "/demos.kl");
+ load_file(my_env, "klsrc/stdlib.kl");
printf(" ready\n");
return 0;
}
// converts strings that are indeed supposed to be 'strings'
// into properly escaped versions of themselves
// i.e. the two-character "\n" gets converted to the single-character newline
- char* out = malloc(sizeof(char)*strlen(s));
+ char* out = malloc(sizeof(char)*(strlen(s)+1));
char* outidx = out;
char* sidx = s; // index on s
char tmp[3] = {0, 0, 0};