home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
OL.LZH
/
PROCS.LZH
/
TYPECODE.ICN
< prev
next >
Wrap
Text File
|
1991-07-13
|
1KB
|
32 lines
############################################################################
#
# Name: typecode.icn
#
# Title: Produce one-letter code for Icon type
#
# Author: Ralph E. Griswold
#
# Date: September 7, 1990
#
############################################################################
#
# typecode(x) produces a one-letter string identifying the type of
# its argument. In most cases, the code is the first (lowercase)
# letter of the type, as "i" for the integer type. Structure types
# are in uppercase, as "L" for the list type. All records have the
# code "R". The code "C" is used for the co-expression type to avoid
# conflict for the "c" for the cset type.
#
############################################################################
procedure typecode(x)
local code
# be careful of records and their constructors
if image(x) ? ="record constructor " then return "p"
if image(x) ? ="record" then return "R"
code := type(x)
if code == ("list" | "set" | "table" | "co-expression") then
code := map(code,&lcase,&ucase)
return code[1]
end