[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gforth] words backwards (J. David Boyd)

From: James Gere
Subject: Re: [gforth] words backwards (J. David Boyd)
Date: Fri, 19 May 2017 16:01:16 -0400

     This doesn't list words backwards, but is an oft used approach:
          : counted.word ( k n nt -- k' n' )    2>r dup if 1- 2r> .word 
             else 2r> drop then ;
          : counted-wordlist-words ( k wid -- k' )   0 swap cr 
             ['] counted.word map-wordlist  drop ;
          30 value ktop#
          : ktop ( k -- )    0 max dup to ktop# 
             context @ counted-wordlist-words drop ;
          : top ( -- )   ktop# ktop ;

     The above, rather inefficient code, works on android gforth.
Other istallations may need some tweeks.

     Listing words backwards isn't terribly hard, but requires storing
the links somewhere: recursion, on the stack or return stack usually;
in an array; or as extra link field in the dictionary headers.    

reply via email to

[Prev in Thread] Current Thread [Next in Thread]