Skip to content

Commit 5b30150

Browse files
author
theBF
committed
Sept updates
1 parent 8f0a97c commit 5b30150

File tree

4 files changed

+34
-20
lines changed

4 files changed

+34
-20
lines changed

DEMO/ELIZA/README.MD

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
# Eliza In Forth
22

3-
This version of the classic Lisp demonstration is a little less sophisticated than the original. A future version may allow programming the responses in Forth allowing for more interesting responses like "In what way is 'X' like 'Y'?" . These were part of the original Lisp version and make the chatbot seem more life-like.
4-
5-
##Instructions
6-
the file ELIZADATA must be on your system on DSK2.
7-
To put convert the PC file to TI-99 you can use the TI-99 Edit program.
8-
9-
1. Paste the file ELIZADATA.FTH into the Editor/Assembler Editor program.
10-
2. Save the file as DSK2.ELIZADATA
11-
12-
##Overview
13-
This implementation creates simple string list syntax in Forth to help manage the replies. A simple string stack provides simple dynamic string creation but the program could have been written without it.
14-
15-
By parsing the user text the program scans for keywords and key phrases. The matched text is converted into a Forth word by removing spaces and punctuation. Armed with a valid Forth word we simply pass it to EVALUATE to kick off Eliza's response.
16-
17-
Lists of responses are created and then compiled as a Forth word with the word REPLY: <name>
18-
19-
Using the list structure for keywords, phrases and conjugations coupled with directly executing Forth "REPLYs" makes modification quite simple.
20-
21-
The file ELIZADATA.FTH contains the source code for the replies. They are separated from the program for ease of editing.
3+
This version of the classic Lisp demonstration in version 3
4+
has been re-written to use the Forth colon definition rather
5+
than strings, as is commonly done in other languages.
6+
A small DSL (domain specific language) was created to allow
7+
the creation of key words and replies that was closer to the
8+
power of LISP.
9+
10+
I was motivated to change the program after looking at the
11+
LISP version of Eliza where you can see LISP's powerful
12+
use of "code" as data.
13+
14+
For example:
15+
```
16+
(((?* ?x) dream about (?* ?y))
17+
(How do you feel about ?y in reality?))
18+
'''
19+
Here we see the ?y inserted into the reply text seamlessly.
20+
This creates a much more natural reply than simply appending
21+
the subject text to the end of a reply phrase.
22+
23+
The equivalent code in this DSL would be:
24+
```
25+
KEY" DREAM ABOUT"
26+
{ :: CR ." How do you feel about " <rogerian> ." in reality?" ;
27+
} REPLY: DREAMABOUT
28+
```
29+
30+
With a little effort this could be further simplfied.

DEMO/SORTS/COMBSORT.FTH

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,7 @@ SIZE CELLS MALLOC CONSTANT Q[]
7070
\ use this to print the array (use FNCT 4 to break out (ALT 4 on PC)
7171
: .Q ( -- ) CR SIZE 0 DO I ]Q @ U. ?BREAK LOOP ;
7272

73-
: GO Q[] SIZE COMBSORT ;
73+
REVERSED
74+
75+
: GO Q[] SIZE COMBSORT ; \ 18.6 seconds
7476

DEMO/SORTS/MERGESORT.FTH

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,7 @@ SIZE CELLS MALLOC CONSTANT Q[]
6464
\ use this to print the array (use FNCT 4 to break out (ALT 4 on PC)
6565
: .Q ( -- ) CR SIZE 0 DO I ]Q @ U. ?BREAK LOOP ;
6666

67+
REVERSED
68+
6769
: GO Q[] SIZE MSORT ; \ 41 SECONDS
6870

DEMO/SORTS/QUICKSORT.FTH

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ SIZE CELLS MALLOC CONSTANT Q[]
6969
\ use this to print the array (use FNCT 4 to break out (ALT 4 on PC)
7070
: .Q ( -- ) CR SIZE 0 DO I ]Q @ U. ?BREAK LOOP ;
7171

72+
REVERSED
7273
: GO Q[] SIZE QUICKSORT ; \ 4.4 SECONDS
7374

7475

0 commit comments

Comments
 (0)