Reverse words in a string: Difference between revisions

Line 837:
 
=={{header|Forth}}==
The method shown is based on submissions in comp.lang.forth. Comments have been added for those less familiar with reading Forth. This example makes use of the internal Forth parserinterpreter/compiler andinternals callsby calling PARSE-NAME which is a Forth 2012 word that parses the input stream, ignores leading spaces and delimits at the space character. This method makes clever use of the data stack. Strings are not copied in memory by rather pointers are collected on the stack as PARSE-NAME processes a sentence. This of course leaves the strings in the reversed order so they are simply printed off the data stack.
<lang>create buf 1000 chars allot \ string buffer
buf value pp \ pp points to buffer address
Anonymous user