• PostScript as a unix shell tool

    From luser- -droog@21:1/5 to All on Mon Jan 3 10:37:05 2022
    [separately posted to comp.lang.postscript bc gg won't crosspost]

    I cooked up this little example for a thread in comp.lang.forth
    about "RPN languages of the future".

    $ cat toolbag.ps
    %!
    <<
    /each-line { 1 dict begin {proc src}{exch def}forall
    src type /stringtype eq { /src src (r) file store } if
    { src 1024 string readline {proc}{pop exit} ifelse } loop
    end }
    /contains { search { pop pop pop true }{ pop false } ifelse }
    /map { 1 index xcheck 3 1 roll [ 3 1 roll forall ] exch {cvx} if }
    /reduce { exch dup first exch rest 3 -1 roll forall }
    /first { 0 get }
    /rest { 1 1 index length 1 sub getinterval }
    begin

    $ gsnd -q -dNOSAFER toolbag.ps -c '[(toolbag.ps){(a)contains{1}{0}ifelse}each-line]{add}reduce = quit'
    6
    $ gsnd -q -dNOSAFER toolbag.ps -c '[(toolbag.ps){(a)contains{1}if}each-line]length = quit'
    6


    Perhaps an

    $ alias gsq='gsnd -q -dNOSAFER'

    would help, too.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)