home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / OL.LZH / PROCS.LZH / TYPECODE.ICN < prev    next >
Text File  |  1991-07-13  |  1KB  |  32 lines

  1. ############################################################################
  2. #
  3. #    Name:    typecode.icn
  4. #
  5. #    Title:    Produce one-letter code for Icon type
  6. #
  7. #    Author:    Ralph E. Griswold
  8. #
  9. #    Date:    September 7, 1990
  10. #
  11. ############################################################################
  12. #
  13. #  typecode(x) produces a one-letter string identifying the type of
  14. #  its argument. In most cases, the code is the first (lowercase)
  15. #  letter of the type, as "i" for the integer type. Structure types
  16. #  are in uppercase, as "L" for the list type. All records have the
  17. #  code "R".  The code "C" is used for the co-expression type to avoid
  18. #  conflict for the "c" for the cset type.
  19. #
  20. ############################################################################
  21.  
  22. procedure typecode(x)
  23.    local code
  24.                 # be careful of records and their constructors
  25.    if image(x) ? ="record constructor " then return "p"
  26.    if image(x) ? ="record" then return "R"
  27.    code := type(x)
  28.    if code == ("list" | "set" | "table" | "co-expression") then
  29.       code := map(code,&lcase,&ucase)
  30.    return code[1]
  31. end
  32.