Commands by List Type

The following section details the commands that perform common operations on each type of list. Refer to prior tables for functions common to all lists, such as min(), max(), and count().

Determining a List’s Type

You may need to determine a list’s type to decide which commands to use with it. You can use listP() to determine whether a datum is any of the four possible types of lists, and you can use ilk() for more detailed information about a list’s type. You can use listP() in if...then statements and ilk() in case statements (see Chapter 5 for a comparison between ilk() and listP()). Two forms of the ilk() command are used with lists:

ilk(variableName)

This form of ilk() returns a symbol indicating the data type of the item, such as #list, #propList, #rect, or #point for the four list types. Note that linear lists return #list, not #linearList. There are dozens of possible return values when using ilk() with other data types, such as #integer and #float. See Table 5-4.

ilk(variableName, #dataType)

This form of ilk() returns a Boolean indicating whether the item is of the specified data type. Note that ilk(list, #list) returns TRUE for all types of lists and is equivalent to listP(list). Use ilk(list, #linearList) to check only whether a list is a linear list. There are many symbols against which you can check an item’s data type, as shown in Table 16-1.

With the exception of #list and #linearList, note that these two forms of ilk() are equivalent when used with ...

Get Lingo in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.