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)
<> (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)
<> (?: 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 ?~) (?~)
<> (?: 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 ')
<> (?: 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 ?:) (?:)

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 (?*)) (reverse List (?*) ())

View File

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

View File

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