%!PS % begin included library code % see https://codeberg.org/Firedrake/postscript-libraries/ /s2a { [ exch { } forall ] } bind def /test.start { print (:) print /test.pass 0 def /test.count 0 def } bind def /map { % array proc -> array 2 dict begin /p exch def [ exch { p } forall ] end } bind def /dget { 3 1 roll 2 copy known { get exch pop } { pop pop } ifelse } bind def /test.end { ( ) print test.count 0 gt { (Passed ) print test.pass (...) cvs print (/) print test.count (...) cvs print ( \() print test.pass 100 mul test.count idiv (...) cvs print (%\)) print (\r\n) print } if } bind def /keys { % dict -> array of dict keys [ exch { pop } forall ] } bind def /deepcopy { 2 dict begin /a exch def a type /dicttype eq { << a keys { /k exch def k a k get deepcopy } forall >> } { a type /arraytype eq { [ a { deepcopy } forall ] } { a type /stringtype eq { a dup length string cvs } { a } ifelse } ifelse } ifelse end } bind def /test { /test.count test.count 1 add def { /test.pass test.pass 1 add def } { ( ) print test.count (....) cvs print (-fail) print } ifelse } bind def /deepeq { 2 dict begin /a exch def /b exch def a type b type eq { a type /dicttype eq { a length b length eq { << a { pop true } forall b { pop true } forall >> true exch { pop dup a exch known { dup b exch known { dup a exch get exch b exch get deepeq not { pop false } if } { false } ifelse } { false } ifelse } forall } { false } ifelse } { a type dup /arraytype eq exch /stringtype eq or { a length b length eq { true 0 1 a length 1 sub { dup a exch get exch b exch get deepeq not { pop false exit } if } for } { false } ifelse } { a b eq } ifelse } ifelse } { false } ifelse end } bind def % end included library code /commoncharacters { 0 dict begin /a exch def [ a { /h 0 dict def s2a { /c exch def h c 2 copy 0 dget 1 add put } forall h } forall ] /ac exch bind def /vc ac 0 get deepcopy def ac { /aa exch def vc keys { /c exch def aa c known { vc c 2 copy get aa c get min put } { vc c undef } ifelse } forall } forall [ a 0 get s2a { /c exch def vc c known { c vc c 2 copy get 1 sub put vc c get 0 eq { vc c undef } if } if } forall ] { 1 string dup 3 2 roll 0 exch put } map end } bind def (commoncharacters) test.start [(java) (javascript) (julia)] commoncharacters [(j) (a)] deepeq test [(bella) (label) (roller)] commoncharacters [(e) (l) (l)] deepeq test [(cool) (lock) (cook)] commoncharacters [(c) (o)] deepeq test test.end