Digest #220 2023-04-10


[294] 2023-04-09 12:41:33 JimPeterson wrote:

referenceImplementation - Possible Reference Implementation

I think this is effectively:

: BLANK ( c-addr u -- )

[295] 2023-04-09 18:50:46 JimPeterson wrote:

referenceImplementation - Possible Reference Implementation

This is the best I could come up with for this one:

: SEARCH {: c-addr1 u1 c-addr2 u2 -- c-addr3 u3 flag :}
  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
  c-addr1 u1 FALSE

The spec saying "... with u<sup>3 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-addr<sup>3 u<sup>3 is the tail end of the c-addr<sup>1 u<sup>1 string, where c-addr<sup>3 u<sup>2 is the same string as c-addr<sup>2 u<sup>2 (when a match is found)

There is also no mention of whether or not the search proceeds forwards from c-addr<sup>1 or backwards from c-addr<sup>1+u<sup>1-u<sup>2, or what happens if c-addr<sup>2 u<sup>2 appears multiple times in c-addr<sup>1 u<sup>1. It should maybe say "... for the first occurrence of the string specified by c-addr<sup>2 u<sup>2."


[r1007] 2023-03-12 20:01:11 ruv replies:

referenceImplementation - Possible Reference Implementation

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.