Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail Newsgroups: comp.lang.forth Subject: Re: On the importance of standards References: <71f94034-0c99-4f1b-bb95-de47aa45947d@g7g2000vbv.googlegroups.com> <2013Jun4.152046@mips.complang.tuwien.ac.at> <2013Jun4.154032@mips.complang.tuwien.ac.at> <86d88732-d90e-4400-9897-c216372f1ba0@bh5g2000vbb.googlegroups.com> <85bo7l7tjp.fsf@junk.nocrew.org> <097aa98a-f890-4aa4-b97e-f75182cb4c40@q6g2000vbh.googlegroups.com> From: Lars Brinkhoff Organization: nocrew Date: Tue, 04 Jun 2013 19:16:57 +0200 Message-ID: <857gi97q46.fsf@junk.nocrew.org> User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) Cancel-Lock: sha1:SJF0LgEBI8fHaUBu105MjmGGVEU= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 38 NNTP-Posting-Host: 85.229.87.73 X-Trace: news.sunsite.dk DXC=n<:Fl_a0>0Fc8biIGL=c`GYSB=nbEKnkKTB9ZjHPY?CC@ON7A^J=91E:[KId_d;k;OecS2QjHQi^GHL>PhDc7DbEA@RQ[nH6m7O X-Complaints-To: staff@sunsite.dk Xref: csiph.com comp.lang.forth:23174 Alex McDonald writes: >> Some time ago, I sent you an email with my experience implementing >> SEARCH-WORDLIST using version 5 of your TRAVERSE-WORDLIST. I >> wasn't happy with the result, but I'm not sure the fault wasn't on >> my part. > > It will have gone into the spam infested trap email address I use > for Google Groups. Do you want to discuss it here? It will be of > interest to more than just me. For most of my uses, the TRAVERSE-WORDLIST interface worked fine. However, in this case I couldn't seem to find a satisfactory solution. I'll just present my attempt here, and all you guys can pick it apart. The problem is that SEARCH-WORDLIST wants to know whether TRAVERSE- WORDLIST had a hit or not. The code below should work, but I'm not happy about the double flags. (And I wanted to avoid TROW and - cough - R> DROP.) I may well be missing something obvious, in which case I'm willing to make a public spectacle of my self for a good cause. \ I'm assuming something like this: \ nt>xt&flag ( nt -- xt 1 | xt -1 ) \ Have to return two flags. One is consumed by traverse-wordlist, \ the other is left on the stack after traverse-wordlist has returned. : ?nt>xt ( caddr u 1 nt -- xt ? 0 0 | caddr u 1 1 ) nip 3dup nt>string compare 0= ( caddr u nt flag ) if nip nip nt>xt&flag 0 0 \ Remove caddr u and terminate traversal. else drop 1 1 \ Remove nt and keep traversing. then ; : search-wordlist ( caddr u wid -- 0 | xt ? ) 1 swap ['] ?nt>xt ( caddr u 1 wid ) traverse-wordlist ( caddr u 1 | xt ? 0 ) if 2drop 0 then ;