add d:words-with from Kiyohsi

FossilOrigin-Name: bed24347b34e3fdca0a8a6d322fc4aa2a0b2319910f5e7393f2c43ad53605d82
This commit is contained in:
crc 2018-05-09 12:13:01 +00:00
parent 09d29752fb
commit 234c225d5b
4 changed files with 28 additions and 0 deletions

View file

@ -29,6 +29,7 @@ Core Language:
- renamed `getc` to `c:get`
- renamed `gets` to `s:get`
- renamed `words` to `d:words`
- add `d:words-with`
Interfaces:

View file

@ -1782,6 +1782,18 @@ Class Handler: class:word | Namespace: global | Interface Layer: all
----------------------------------------------------------------
d:words-with
Data: s-
Addr: -
Float: -
Display a list of all named items in the `Dictionary` that contain the provided substring.
Class Handler: class:word | Namespace: global | Interface Layer: all
----------------------------------------------------------------
d:xt
Data: d-a

View file

@ -1479,6 +1479,20 @@ I provide just a few debugging aids.
:dump-stack (-) depth 0; drop push dump-stack pop dup n:put sp ;
~~~
From Kiyoshi Yoneda, this is a variant of `d:words` which displays
words containing a specific substring. It's useful to see words in
a specific namespace, e.g., by doing `'s: d:words-with`, or words
that likely display something: `':puts d:words-with`.
{{
:display-if-matched (s-)
dup here s:contains-string? [ s:put sp ] [ drop ] choose ;
---reveal---
:d:words-with (s-)
here s:copy [ d:name display-if-matched ] d:for-each ;
}}
~~~
:FREE (-n) STRINGS #1025 - here - ;
~~~

View file

@ -141,6 +141,7 @@ d:lookup s-d - - Lookup the specified name in the dictionary and return a pointe
d:lookup-xt a-d - - Lookup the specified address in the dictionary and return a pointer to its dictionary header. This returns zero if the word is not found. class:word {n/a} {n/a} d all
d:name d-s - - Given a dictionary header, return the name field. class:word {n/a} {n/a} d all
d:words - - - Display a list of all named items in the `Dictionary`. class:word {n/a} {n/a} global all
d:words-with s- - - Display a list of all named items in the `Dictionary` that contain the provided substring. class:word {n/a} {n/a} global all
d:xt d-a - - Given a dictionary header, return the xt field. class:word {n/a} {n/a} d all
data - - - Change the class of the most recently defined word to `class:data`. class:word {n/a} {n/a} global all
depth -n - - Return the number of items on the stack. class:word {n/a} {n/a} global all

1 * nn-n - - Multiply `n1` by `n2` and return the result. class:primitive #2 #6 *\n #-1 #100 * {n/a} global all
141 d:lookup-xt a-d - - Lookup the specified address in the dictionary and return a pointer to its dictionary header. This returns zero if the word is not found. class:word {n/a} {n/a} d all
142 d:name d-s - - Given a dictionary header, return the name field. class:word {n/a} {n/a} d all
143 d:words - - - Display a list of all named items in the `Dictionary`. class:word {n/a} {n/a} global all
144 d:words-with s- - - Display a list of all named items in the `Dictionary` that contain the provided substring. class:word {n/a} {n/a} global all
145 d:xt d-a - - Given a dictionary header, return the xt field. class:word {n/a} {n/a} d all
146 data - - - Change the class of the most recently defined word to `class:data`. class:word {n/a} {n/a} global all
147 depth -n - - Return the number of items on the stack. class:word {n/a} {n/a} global all