Bernd Paysan <bernd.pay...@gmx.de> writes:

> Am Freitag, 19. Mai 2017, 18:09:30 CEST schrieb Dennis Ruffer:
>> Since Forth dictionaries are typically, singly linked lists, it would take
>> memory and time to reverse the order.
>
> Yes, but on a desktop system, we actually have that memory. And time is even 
> less important.  This does it, by converting the list into an array and then 
> stepping backwards through that array:
>
> Variable words[]
>
> : words ( -- )
>     [: words[] dup $[]# swap $[] ! true ;] context @ traverse-wordlist
>     source nip 1+ words[] $@ bounds cell- swap cell- U-DO
>       I @ .word
>     cell -LOOP drop
>     words[] $free ;
>
> Works in the current development system.


I'll have to brush up on my forth to figure out what this does.  Been too many
years since I did anything non-trivial with it.

Thanks for the code!


Reply via email to