,---------------.
| Contributions |
`---------------´
,------------------------------------------
| 2023-04-09 12:41:33 JimPeterson wrote:
| referenceImplementation - Possible Reference Implementation
| see: https://forth-standard.org/standard/string/BLANK#contribution-294
`------------------------------------------
I think this is effectively:
```
: BLANK ( c-addr u -- )
BL FILL
;
```
,------------------------------------------
| 2023-04-09 18:50:46 JimPeterson wrote:
| referenceImplementation - Possible Reference Implementation
| see: https://forth-standard.org/standard/string/SEARCH#contribution-295
`------------------------------------------
This is the best I could come up with for this one:
```
: SEARCH {: c-addr1 u1 c-addr2 u2 -- c-addr3 u3 flag :}
c-addr1
u1 u2 - 1+ 0 MAX 0 ?DO \ only search up to u1-u2 characters
DUP u2 c-addr2 u2 COMPARE 0= IF
u1 I - TRUE UNLOOP EXIT \ u3 is u1 minus however far we scanned in
THEN
CHAR+
LOOP
DROP
c-addr1 u1 FALSE
;
```
The spec saying "... with *u3* characters remaining." sounds a bit vague to me, but I took it to mean that `c-addr3 u3 CHARS + c-addr1 u1 CHARS + =`, which is to say that *c-addr3* *u3* is the tail end of the *c-addr1* *u1* string, where *c-addr3* *u**2*** is the same string as *c-addr2* *u2* (when a match is found)
There is also no mention of whether or not the search proceeds forwards from *c-addr1* or backwards from *c-addr1+u1-u2*, or what happens if *c-addr2* *u2* appears multiple times in *c-addr1* *u1*. It should maybe say "... for the first occurrence of the string specified by *c-addr2* *u2*."
,---------.
| Replies |
`---------´
,------------------------------------------
| 2023-03-12 20:01:11 ruv replies:
| referenceImplementation - Possible Reference Implementation
| see: https://forth-standard.org/standard/core/CONSTANT#reply-1007
`------------------------------------------
Yes, it's a possible and fully compliant implementation. I use this approach.
Please, include also a correct stack diagram into your definitions. It's also an ask to all contributors of reference implementations.