Strip comments from a string: Difference between revisions

m
Line 613:
 
=={{header|Forth}}==
Modern Forth advocates the use of stack strings. Stack strings are manipulated as an address and a length on the Forth DATA stack. As such they do not require memory copying for many forms of string functions making them fast. Stack Usingstring stackfunctions stringstypically andreturn concatenatinga functionsstack meansstring Forthallowing doesconcatenation thisof taskstring with no REGEX requiredfunctions.
 
NOTES:
Line 619:
1. SCAN is not a standard function but is common in most Forth systems as either a library function or resident.
 
2. -TRAILING is a resident function in most Forth systems. Shown for clarity.
2. FORTH style factoring means you can strip the comments and strip trailing spaces or not, as you see fit.
Tested with Swift Forth on OS/X, GForth on Windows
Or Concatenate the functions together as we did here.
 
Tested with Swift Forth on OS/X, GForth on Windows
 
<LANG FORTH>\ Rosetta Code Strip Comment
: LASTCHAR ( addr len -- addr len c) 2DUP + C@ ;
Anonymous user