Queries
Test data or data contents.
COUNT
Counts the number of items in its input.
Syntax
COUNT word
COUNT list
Description
COUNT reports the number of elements in its input. If its input is a word, COUNT reports the number of characters. If the input is a list, COUNT reports the number of elements in the list.
Example
COUNT “ELEMENTARY Result: 10 COUNT [ELEMENTARY] Result: 1 COUNT [[MT. WASHINGTON] [MT. RAINIER] [MAUNA LOA]] Result: 3
DEFINED?
Also: DEFINEDP
Checks whether a procedure is defined.
Syntax
DEFINED? name
Description
DEFINED? reports TRUE if the input is a name of a primitive procedure or a user-defined procedure; otherwise it reports FALSE. Compare with PROCEDURE?, which reports TRUE only if the input is a user-defined procedure, and PRIMITIVE?, which reports TRUE only if the input is a built-in command.
Example
DEFINED? “FORWARD Result: TRUE
EMPTY?
Also: EMPTYP
Checks whether a name is empty.
Syntax
EMPTY? word
EMPTY? list
Description
EMPTY? reports TRUE if the input is the empty word (“||) or the empty list ([]); otherwise, it reports FALSE.
Example
MAKE “FRUIT “|| EMPTY? :FRUIT Result: TRUE MAKE “FRUIT [PAPAYA] EMPTY? :FRUIT Result: FALSE
LIST?
Also: LISTP
Checks for its input being a list.
Syntax
LIST? object
Description
LIST? reports TRUE if its input is a list; otherwise, it reports FALSE. See also TYPEOF, NUMBER? and WORD?.
Example
LIST? [GREEN BLUE] Result: TRUE LIST? “GREEN Result: FALSE LIST? [] Result: TRUE
MACRO?
Also: MACROP
Checks its input for being a macro.
Syntax
MACRO? word
Description
MACRO? reports TRUE if the input word is the name of a Logo macro; otherwise, it reports FALSE. Compare with DEFINED?, which reports TRUE for both primitives and procedures, and PROCEDURE?, which reports FALSE for primitives and TRUE for user-defined procedures. All these commands report similarly for both buried and unburied procedures. See also .MACRO and .DEFMACRO for more information about macros.
Example
MACRO? “FD Result: FALSE DEFINED? “FD Result: TRUE
MEMBER?
Also: MEMBERP
Checks if an object is part of another object.
Syntax
MEMBER? word-or-list word-or-list
(MEMBER? word-or-list word-or-list TRUE)
Description
MEMBER? reports TRUE if the first input is an element of the second input; otherwise it reports FALSE.
If the second input is a list, MEMBER? compares each element of the list. It does not scan any sublists, unless it is caled with a third, optional input set to TRUE.
Example
MEMBER? “A “ABC Result: TRUE MEMBER? [INSIDE] [A [B [INSIDE] C] D] Result: FALSE (MEMBER? [INSIDE] [A [B [INSIDE] C] D] TRUE) Result: TRUE
NAME?
Also: NAMEP
Checks whether its input is assigned a value.
Syntax
NAME? name
Description
NAME? reports TRUE if the input is a name of a variable; otherwise; it reports FALSE. See also TYPEOF, LIST?, NUMBER?, and WORD?.
Example
ERASE “ANIMAL NAME? “ANIMAL Result: FALSE MAKE “ANIMAL “CAT NAME? “ANIMAL Result: TRUE
NUMBER?
Also: NUMBERP
Checks its input for being a number.
Syntax
NUMBER? object
Description
NUMBER? reports TRUE if its input is a number; otherwise it reports FALSE. Note that Logo treats quoted numbers or numbers that have been put together as numbers as well. See also LIST?, NAME?, and WORD?.
Example
NUMBER? WORD “4 “1 Result: TRUE NUMBER? 41 Result: TRUE NUMBER? [41] Result: FALSE NUMBER? FIRST [41] Result: TRUE NUMBER? 4.1 Result: TRUE
PLIST?
Also: PLISTP
Checks its input for containing a property list.
Syntax
PLIST? word
Description
PLIST? outputs TRUE if a property list exists under the given name, FALSE otherwise.
Example
PLIST “A Result: FALSE PPROP “A “B “C PLIST? “A Result: TRUE
PRIMITIVE?
Also: PRIMITIVEP
Checks its input for being a built-in procedure or macro.
Syntax
PRIMITIVE? word
Description
PRIMITIVE? reports TRUE if the input word is the name of a built-in Logo command or macro; otherwise, it reports FALSE. User-defined procedures or macros are not considered primitives; hence PRIMITIVE? reports FALSE when given their names as input. Compare with DEFINED?, which reports TRUE for both primitives, macros and procedures, and PROCEDURE?, which reports FALSE for primitives and TRUE for user-defined procedures and macros. All these commands report similarly for both buried and unburied procedures and macros. Remember that a macro is a special form of a procedure, see .MACRO for details.
Example
PRIMITIVE? “FD Result: TRUE PROCEDURE? “FD Result: FALSE DEFINED? “FD Result: TRUE
PROCEDURE?
Also: PROCEDUREP
Checks its input for being a user-defined procedure.
Syntax
PROCEDURE? word
Description
PROCEDURE? reports TRUE if the input word is the name of a user-defined Logo procedure; otherwise, it reports FALSE. Compare with DEFINED?, which reports TRUE for both primitives and procedures, and PRIMITIVE?, which reports TRUE for primitives and FALSE for user-defined procedures. All these commands report similarly for both buried and unburied procedures.
Example
TO SAY.HELLO PRINT “HELLO END SAY.HELLO defined PRIMITIVE? “SAY.HELLO Result: FALSE PROCEDURE? “SAY.HELLO Result: TRUE DEFINED? “SAY.HELLO Result: TRUE
WORD?
Also: WORDP
Checks its input for being a word.
Syntax
WORD? object
Description
WORD? reports TRUE if its input is a word; otherwise it reports FALSE. See also LIST?, NAME?, and NUMBER?.
Example
WORD? 123 Result: TRUE WORD? “FD Result: TRUE WORD? [FD] Result: FALSE