aboutsummaryrefslogtreecommitdiff
path: root/amforth-6.5/common/lib/forth2012/core/find.frt
diff options
context:
space:
mode:
Diffstat (limited to 'amforth-6.5/common/lib/forth2012/core/find.frt')
-rw-r--r--amforth-6.5/common/lib/forth2012/core/find.frt21
1 files changed, 21 insertions, 0 deletions
diff --git a/amforth-6.5/common/lib/forth2012/core/find.frt b/amforth-6.5/common/lib/forth2012/core/find.frt
new file mode 100644
index 0000000..a289cc8
--- /dev/null
+++ b/amforth-6.5/common/lib/forth2012/core/find.frt
@@ -0,0 +1,21 @@
+\ #require count.frt
+
+: find ( addr -- addr 0 | xt -1 | xt 1 )
+ dup count find-xt dup
+ if rot drop then
+;
+
+\ \ find-xt is using the order stack
+\ \ with map-stack as iterator.
+\ : (find-xt) ( addr len wid -- addr len 0 | xt +/-1 -1 )
+\ >r 2dup r> search-wordlist
+\ dup if
+\ >r nip nip r> -1
+\ then
+\ ;
+\
+\ : find-xt
+\ ['] (find-xt) 'ORDER map-stack
+\ 0= if 2drop 0 then
+\ ;
+