Plan 9 from Bell Labs’s /usr/web/sources/contrib/fgb/root/sys/src/cmd/4th/lib/filter.4th

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


\ 4tH library - FILTER - Copyright 2004 J.L. Bezemer
\ You can redistribute this file and/or modify it under
\ the terms of the GNU General Public License

[UNDEFINED] filter [IF]
: filter                               ( a n1 c -- a n2)
  >r >r dup dup dup dup r> chars + >r  \ setup parameters
  begin                               
    begin                              \ search non-filter character
      dup r@ <> dup                    \ end of line?
      if over c@ r'@ = over and else dup then
    while                              \ is it the filter character?
      drop char+                       \ if not, next character
    repeat                             \ and drop the flag
  while                                \ store the character
     swap >r dup c@ r@ c! char+ r> char+ swap
  repeat                               \ calculate length new string
  r> r> drop drop drop swap chars -
;
[THEN]


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.