-----Original Message----- From: Bernd Paysan [mailto:bernd.pay...@gmx.de] Sent: Friday, May 19, 2017 12:24 PM To: gforth@gnu.org Cc: Dennis Ruffer <daruf...@gmail.com>; David Boyd CW <dbo...@mmm.com> Subject: [EXTERNAL] Re: [gforth] words backwards
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. -- Bernd Paysan "If you want it done right, you have to do it yourself" net2o ID: kQusJzA;7*?t=uy@X}1GWr!+0qqp_Cn176t4(dQ* http://bernd-paysan.de/ Thanks so much, exactly what I was looking for.