File:  [CSRG BSD Unix] / 43BSD / contrib / icon / samples / cross.icn
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:55 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD43
BSD 4.3

#
#          W O R D   I N T E R S E C T I O N S
#

#  This program procedure accepts string pairs from standard input, with
#  the strings separated by semicolons.  It then diagrams all the
#  intersections of the two strings in a common character.

procedure main()
   local line, j
   while line := read() do {
      write()
      j := upto(':',line)
      cross(line[1:j],line[j+1:0])
      }
end

procedure cross(s1,s2)
   local j, k
   every j := upto(s2,s1) do
      every k := upto(s1[j],s2) do
         xprint(s1,s2,j,k)
end

procedure xprint(s1,s2,j,k)
   write()
   every write(right(s2[1 to k-1],j))
   write(s1)
   every write(right(s2[k+1 to *s2],j))
end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.