From 9b5212cb45120aa69700c83cf3aaae1ce48a9b0a Mon Sep 17 00:00:00 2001 From: crc Date: Wed, 20 Jun 2018 13:03:22 +0000 Subject: [PATCH] updates to some examples FossilOrigin-Name: 6efdcd9c4a9455a2f908fa727dae442aee8f7c3e5a5d6c4d09f1ad53960d9d89 --- example/AddingVectors.forth | 4 ++-- example/Roo.forth | 12 +++--------- example/accumulator.forth | 8 ++++---- example/is-palindrome.forth | 3 ++- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/example/AddingVectors.forth b/example/AddingVectors.forth index e5fd826..8517687 100644 --- a/example/AddingVectors.forth +++ b/example/AddingVectors.forth @@ -10,7 +10,7 @@ This is an example adding two three element vectors. A test case: -~~~ +``` 'a d:create #1 , #2 , #3 , 'b d:create #2 , #3 , #4 , 'c d:create #3 allot @@ -20,5 +20,5 @@ A test case: &c fetch-next n:put nl fetch-next n:put nl fetch n:put nl -~~~ +``` diff --git a/example/Roo.forth b/example/Roo.forth index e063122..5865174 100755 --- a/example/Roo.forth +++ b/example/Roo.forth @@ -1,8 +1,7 @@ -#/bin/sh +#!/bin/sh stty cbreak cat >/tmp/_roo.forth << 'EOF' - # Roo: A Block Editor for RETRO This implements a block editor for RETRO. It provides a visual interface, @@ -51,7 +50,6 @@ the currently loaded block. ~~~ - ## Server Communication With that done, it's now time for a word to load a block from the @@ -80,13 +78,12 @@ And then words to actually talk to the server: ~~~ :load-block (-) &Block SERVER selector gopher:get drop ; -:save-block (-) here SERVER selector gopher:get drop ; +:save-block (-) here SERVER selector gopher:get drop ; ~~~ All done :) - ## Modes The `Mode` variable will be used to track the current mode. I have @@ -105,7 +102,6 @@ $C 'Mode var ~~~ - ## Cursor & Positioning I need a way to keep track of where in the block the user currently is. @@ -150,7 +146,6 @@ The last bit here is `insert-character` which inserts a character to ~~~ - ## Keyboard Handling Handling of keys is essential to using Roo. I chose to use a method that @@ -251,7 +246,6 @@ if editing is finished. ~~~ - ## Display The block display is kept minimalistic. Each line is bounded by a single @@ -302,7 +296,6 @@ The cursor display will be platform specific. ~~~ - ## The Final Piece All that's left is a single top level loop to tie it all together. @@ -317,6 +310,7 @@ edit ~~~ + EOF rre /tmp/_roo.forth rm -f /tmp/_roo.forth diff --git a/example/accumulator.forth b/example/accumulator.forth index 0c85e28..3667ed2 100644 --- a/example/accumulator.forth +++ b/example/accumulator.forth @@ -35,8 +35,8 @@ This removes the primitive stack shuffling, and leaves something that expresses Finally, here's a little test case: ``` - #10 'foo acc - foo - foo - foo + #10 'foo acc + foo + foo + foo ``` diff --git a/example/is-palindrome.forth b/example/is-palindrome.forth index 0e471eb..ec71a2d 100644 --- a/example/is-palindrome.forth +++ b/example/is-palindrome.forth @@ -12,7 +12,8 @@ and compare them. ~~~ :s:palindrome? (s-f) - dup s:hash [ s:reverse s:hash ] dip eq? ; + [ s:hash ] + [ s:reverse s:hash ] bi eq? ; 'ingirumimusnocteetconsumimurigni s:palindrome? ~~~