Improved examples

This commit is contained in:
Devine Lu Linvega 2024-04-15 16:26:25 -07:00
parent 60325b23a3
commit 205cd340b5
9 changed files with 12 additions and 11 deletions

View File

@ -1,4 +1,4 @@
?(?0 ()) (This example demonstrates how to implement combinatory calculus.) ?(?-) (This example demonstrates how to implement combinatory calculus.)
<> (M ?x) (?x ?x) <> (M ?x) (?x ?x)
<> (KI ?x ?y) (?y) <> (KI ?x ?y) (?y)

View File

@ -1,4 +1,4 @@
?(?0 ()) (This example prints to the console and demonstrates how to delay the execution of a rule.) ?(?-) (This example prints to the console and demonstrates how to delay the execution of a rule.)
<> (NAME) (Modal) <> (NAME) (Modal)
<> (?: print String) (?:) <> (?: print String) (?:)

View File

@ -1,4 +1,4 @@
?(?0 ()) (This example requests 3 line delimited strings from the console.) ?(?-) (This example requests 3 line delimited strings from the console.)
<> (read ?~) (?~) <> (read ?~) (?~)
<> (?: print ') (?:) <> (?: print ') (?:)

View File

@ -1,4 +1,4 @@
?(?0 ()) (This example demonstrates how to keep the runtime active between prompts.) ?(?-) (This example demonstrates how to keep the runtime active between prompts.)
<> ((You said: quit\n) send) ((You quit.) print ') <> ((You said: quit\n) send) ((You quit.) print ')
<> (?: print ') (?:) <> (?: print ') (?:)

View File

@ -1,4 +1,4 @@
?(?0 ()) (This example prints hello world to the console.) ?(?-) (This example prints hello world to the console.)
<> (send ?:) (?:) <> (send ?:) (?:)

View File

@ -1,4 +1,4 @@
?(?0 ()) (This example reverses the string modal, into ladom.) ?(?-) (This example reverses the string modal, into ladom.)
<> (reverse List () ?*) (?*) <> (reverse List () ?*) (?*)
<> (reverse (?*)) (reverse List (?*) ()) <> (reverse (?*)) (reverse List (?*) ())

View File

@ -1,3 +1,5 @@
?(?-) (This example tests various aspects of the implementation.)
<> (explode ?*) (str (?*)) <> (explode ?*) (str (?*))
<> (reverse (str (?h ?t))) (reverse/l ?t (?h)) <> (reverse (str (?h ?t))) (reverse/l ?t (?h))
<> (reverse (str (?h))) (?h) <> (reverse (str (?h))) (?h)

View File

@ -1,4 +1,4 @@
?(?0 ()) (This example demonstrates how to implement a 2-players game of Tic Tac Toe) ?(?-) (This example demonstrates how to implement a 2-players game of Tic Tac Toe)
<> (-- ?x) () <> (-- ?x) ()
<> (READ ?~) (?~) <> (READ ?~) (?~)

View File

@ -140,12 +140,11 @@ parse_frag(char *s)
while((c = *s) && c <= ' ') s++; while((c = *s) && c <= ' ') s++;
if(*s != ')' && *s != '<' && s[1] != '>') { if(*s != ')' && *s != '<' && s[1] != '>') {
ss = walk(s); ss = walk(s);
if(*s == '('){ if(*s == '(') {
s++; s++;
while(s < ss-1) *dict_++ = *s++; while(s < ss - 1) *dict_++ = *s++;
s++; s++;
} } else
else
while(s < ss) *dict_++ = *s++; while(s < ss) *dict_++ = *s++;
} }
*dict_++ = 0; *dict_++ = 0;