Terrapin Resources

Queries

Test data or data contents.


COUNT

Counts the number of items in its input; one 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.

Examples

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; one input.

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.

Examples

DEFINED? “FORWARD Result: TRUE


EMPTY?

Also: EMPTYP

Checks whether a name is empty; one input.

Syntax

EMPTY? word
EMPTY? list

Description

EMPTY? reports TRUE if the input is the empty word (“   ) or the empty list ([]); otherwise, it reports FALSE.

Examples

MAKE “FRUIT “|| EMPTY? :FRUIT Result: TRUE MAKE “FRUIT [PAPAYA] EMPTY? :FRUIT Result: FALSE


LIST?

Also: LISTP

Checks for its input being a list; one input.

Syntax

LIST? object

Description

LIST? reports TRUE if its input is a list; otherwise, it reports FALSE. See also TYPEOF, NUMBER? and WORD?.

Examples

LIST? [GREEN BLUE] Result: TRUE LIST? “GREEN Result: FALSE LIST? [] Result: TRUE


MACRO?

Also: MACROP

Checks its input for being a macro; one input.

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.

Examples

MACRO? “FD Result: FALSE DEFINED? “FD Result: TRUE


MEMBER?

Also: MEMBERP

Checks if an object is part of another object; two inputs.

Syntax

MEMBER? word-or-list word-or-list

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.

If you need the item number of an object inside another object, use ITEM.

Examples

MEMBER? “A “ABC Result: TRUE MEMBER? [INSIDE] [A [B [INSIDE] C] D] Result: FALSE


NAME?

Also: NAMEP

Checks whether its input is assigned a value; one input.

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?.

Examples

ERASE “ANIMAL NAME? “ANIMAL Result: FALSE MAKE “ANIMAL “CAT NAME? “ANIMAL Result: TRUE


NUMBER?

Also: NUMBERP

Checks its input for being a number; one input.

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?.

Examples

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; one input.

Syntax

PLIST? word

Description

PLIST? outputs TRUE if a property list exists under the given name, FALSE otherwise.

Examples

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; one input.

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.

Examples

PRIMITIVE? “FD Result: TRUE PROCEDURE? “FD Result: FALSE DEFINED? “FD Result: TRUE


PROCEDURE?

Also: PROCEDUREP

Checks its input for being a user-defined procedure; one input.

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.

Examples

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; one input.

Syntax

WORD? object

Description

WORD? reports TRUE if its input is a word; otherwise it reports FALSE. See also LIST?, NAME?, and NUMBER?.

Examples

WORD? 123 Result: TRUE WORD? “FD Result: TRUE WORD? [FD] Result: FALSE


EQUAL?

Also: EQUALP, .EQ

Tests its inputs for equality; two inputs.

Syntax

.EQ object object

Description

EQUAL? compares two objects. If they are equal, the output is TRUE; otherwise it is FALSE. The infix operator = does the same for a left and rignt input.

The value of the :EPSILON variable determines how the equality operator compares two numbers. See :EPSILON for details.

Examples

.EQ 5 5 Result: TRUE EQUAL? [6] [6] Result: TRUE EQUAL? 6 [6] Result: FALSE


GREATEREQUAL?

Also: .GE, GREATEREQUALP

Tests if its first input is greater than or equal to its second input; two inputs.

Syntax

.GE word word

Description

GREATEREQUAL? compares two words. If the first word is greater than or equal to the second word, the output is TRUE; otherwise, it is FALSE. The infix operator >= does the same for a left and rignt input.

Examples

GREATEREQUAL? 4 5 Result: FALSE .GE 5 5 Result: TRUE


GREATER?

Also: .GT, GREATERP

Tests if its first input is greater than its second input; two inputs.

Syntax

.GT word word

Description

GREATER? compares two words. If the first word is greater than the second word, the output is TRUE; otherwise it is FALSE. The infix operator > does the same for a left and rignt input.

Examples

.GT 5 5 Result: FALSE


LESSEQUAL?

Also: .LE, LESSEQUALP

Tests if its first input is less than or equal to its second input; two inputs.

Syntax

.LE word word

Description

LESSEQUAL? compares two words. If the first word is less than or equal to the second word, the output is TRUE; otherwise it is FALSE. The infix operator <= does the same for a left and rignt input.

Examples

.LE 4 5 Result: TRUE .LE 5 5 Result: TRUE


LESS?

Also: .LT, LESSP

Tests if its first input is less than its second input; two inputs.

Syntax

.LT number number

Description

LESS? compares two words. If the first word is less than the second word, the output is TRUE; otherwise it is FALSE. The infix operator < does the same for a left and rignt input.

Examples

.LT 4 5 Result: TRUE .LT 5 5 Result: FALSE


NOTEQUAL?

Also: .NE, NOT.EQUAL?, NOTEQUALP, NOT.EQUALP

Tests its inputs for inequality; two inputs.

Syntax

NOTEQUAL? object object

Description

NOTEQUAL? reports TRUE if its two inputs are not equal; otherwise it reports FALSE. Its inputs may be numbers, words, or lists. The infix operator != does the same for a left and rignt input.

The value of the :EPSILON variable determines how the inequality operator compares two numbers. See :EPSILON for details.

Examples

NOTEQUAL? 6 6 Result: FALSE NOTEQUAL? 6 66 Result: TRUE NOTEQUAL? “AZURE “AZURE Result: FALSE NOTEQUAL? [SPRING GREEN] [SPRING GREEN] Result: FALSE NOTEQUAL? “AZURE [AZURE] Result: TRUE