home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-386-Vol-2of3.iso / v / vsnbl220.zip / DIFF.INC < prev    next >
Text File  |  1991-02-14  |  703b  |  26 lines

  1. *    DIFF.INC
  2. *
  3. *    Function to return the difference of two strings.  Given
  4. *    strings S1 and S2, returns the set difference S1 - S2.
  5. *    
  6. *        DIFF('PURPLE','LEP') returns 'UR'.
  7. *
  8. *    Handy for set arithmetic, and to obtain character sets.
  9. *    For example, DIFF(&ALPHABET, &LCASE &UCASE) returns the
  10. *    full ASCII set less the upper- and lower-case characters.
  11. *
  12. *    Requires &ANCHOR = 0
  13. *
  14. *    This is one of the many programs and functions from
  15. *    "Algorithms in SNOBOL4," by James F. Gimpel.
  16.  
  17.     DEFINE('DIFF(S1,S2)')                :(DIFF_END)
  18. DIFF    DIFF = S1
  19.     IDENT(S2)                    :S(RETURN)
  20.     S2 = SPAN(S2)
  21.  
  22. * Remove any occurances of S2's characters from result.
  23. DIFF_1    DIFF S2 =                :S(DIFF_1)F(RETURN)
  24.  
  25. DIFF_END
  26.