Terrapin Resources

Data Commands

The commands in this section create and modify data structures, mostly lists.


ASCII

Also: UNICODE

Converts a character into its Unicode value; one input.

Syntax

UNICODE character
ASCII character

Description

UNICODE reports the Unicode value of its input. The Unicode standard is a standard code for representing numbers, letters and symbols. If its input is a word, UNICODE reports the UNICODE value of the first character in the word. UNICODE reports an integer value. The input must contain at least one character. The character can be a letter, number or special character. To output the character corresponding to an UNICODE code input, use CHAR.

The alias ASCII is maintained for backward compatibility.

Examples

UNICODE “中 Result: 20013


BUTFIRST

Also: BF

Reports all but the first element of its input; one input.

Syntax

BUTFIRST word
BUTFIRST list

Description

BUTFIRST reports all but the first element of its input. If its input is a list, BUTFIRST reports a list containing all but the first element. If its input is a word or number, BUTFIRST reports all the characters of the word or number except the first character. See also BUTMEMBER, BUTLAST, FIRST, and LAST.

Examples

BUTFIRST [MARY HAD A LITTLE LAMB] Result: [HAD A LITTLE LAMB] BUTFIRST “WHEAT Result: HEAT BUTFIRST [WHEAT] Result: [] BUTFIRST 2135 Result: 135 BUTFIRST [[JANUARY FEBRUARY][MARCH APRIL] [MAY JUNE]] Result: [[MARCH APRIL] [MAY JUNE]]


BUTLAST

Also: BL

Reports all but the last element of its input; one input.

Syntax

BUTLAST word
BUTLAST list

Description

BUTLAST reports all but the last element of its input. If the input is a list, BUTLAST reports a list containing all but the last element. If the input is a word or number, BUTLAST reports all the characters of the word or number except the last character. See also BUTMEMBER, BUTFIRST, FIRST, and LAST.

The procedure in the example makes a plural word or list of words into singular form (for words that are made plural by adding the letter S).

Examples

TO SINGULAR :WORD IF EMPTY? :WORD THEN STOP PRINT BUTLAST FIRST :WORD SINGULAR BUTFIRST :WORD END Result: SINGULAR defined SINGULAR [CATS] Result: CAT SINGULAR [BOOKS TOOLS FLOWERS EYES RUNS] Result: BOOK TOOL FLOWER EYE RUN


BUTMEMBER

Also: BM, REMOVE

Removes elements from a word or a list; two inputs.

Syntax

BUTMEMBER word word
BUTMEMBER word.or.list list

Description

BUTMEMBER reports a word or list consisting of its second input with all occurrences of its first input removed. If the second input is a word, the first input must also be a word. If the second input is a list, the first input can be either a word or list.

See also BUTFIRST and BUTLAST.

Examples

BUTMEMBER “AM [HI I AM FRED] Result: [HI I FRED] BM “D “ABCDABCDABCD Result: ABCABCABC BUTMEMBER 22 [11 22 33 44 55] Result: [11 33 44 55] BUTMEMBER [JANUARY 1] [[JANUARY 1][JULY 4][DECEMBER 25]] Result: [[JULY 4][DECEMBER 25]]


CHAR

Converts a number into a Unicode character; one input.

Syntax

CHAR number

Description

CHAR reports the character whose Unicode code is the input. The input number can be from 0 through #H10FFFF (1114111). To output the Unicode code corresponding to an input character, use UNICODE.

Use caution when saving a Logo name or procedure that contains unprintable characters, like characters with a value of less than 32. Logo saves them as is without escaping them. If you, for example, save a value that contains a newline character (CHAR 10), then Logo may not be able to read that file correctly.

Examples

CHAR 20013 Result: 中


DATE

Reports the date; no inputs.

Syntax

DATE

Description

DATE reports the current date as a four-element list in the form [day month year dayofweek]. The dayofweek is a number from 1 to 7, starting at Sunday. Use TIME to get the current time.

Examples

DATE Result: [21 07 2025 5]


FIRST

Reports the first element of its input; one input.

Syntax

FIRST word
FIRST list

Description

FIRST reports the first element of its input. If the input is a word, FIRST reports the first character. If the input is a list, FIRST reports the first element of that list. If the word or list is empty, there is no first element, and FIRST throws an error. See also BUTFIRST, BUTLAST, and LAST.

Examples

FIRST [MARY HAD A LITTLE LAMB] Result: MARY FIRST “WHEAT Result: W FIRST 2135 Result: 2


FLATTEN

Reports a flat version of its list input; one input.

Syntax

FLATTEN list

Description

FLATTEN takes a list as its input and converts it to a flat list. The elements of all sublists in the list are appended to that flat list, as are the elements of their sublists. If FLATTEN is called with an input that is not a list, FLATTEN reports its input.

Examples

FLATTEN [HI [[LUCY ANN] SMITH]] Result: [HI LUCY ANN SMITH] FLATTEN 123 Result: 123


FPUT

Prepends an element to its input; two inputs.

Syntax

FPUT word word
FPUT word list
FPUT list list

Description

FPUT reports the word or list that is created by putting the first input at the beginning of the second input. If both inputs are words, FPUT reports a word; otherwise it reports a list. See also LIST, LPUT, SENTENCE, and WORD.

Examples

FPUT “A “BC Result: ABC FPUT 1 23 Result: 123 FPUT “A [GREEN CHEVY] Result: [A GREEN CHEVY] FPUT [NORTH DAKOTA] [NEW HAMPSHIRE] Result: [[NORTH DAKOTA] NEW HAMPSHIRE]


FROMMEMBER

Also: FM

Removes the first part of its input until a specified word or list is found; two inputs.

Syntax

FROMMEMBER word word
FROMMEMBER wordorlist list

Description

FROMMEMBER reports a word or list consisting of its second input with all elements removed up until the first occurrence of its first input. If the second input is a word, the first input must also be a word. If the second input is a list, the first input can be either a word or a list.

Examples

FROMMEMBER “B “ABC Result: BC FROMMEMBER 3 [1 2 3 4 5] Result: [3 4 5] FROMMEMBER “HAT “MANHATTAN Result: HATTAN FM “CHARLIE [ARCHIE BETSY CHARLIE DINAH EDWARD FRANCIS] Result: [CHARLIE DINAH EDWARD FRANCIS]


ISEQ

Outputs a list of sequential integers; expects between two inputs and three inputs, but parentheses are needed if not called with two inputs.

Syntax

ISEQ from to
(ISEQ from to increment)

Description

ISEQ outputs a list of the integers from “from” to “to”, inclusive. If an increment is given as an optional third input, the integers are created using the given increment; if no increment is given, the increment is 1 if “from” is less than “to”, or -1 if “from” is greater than “to”. Note that if the increment is not 1 or -1, the “to” value may not be part of the list; for example, the output of (ISEQ 1 5 3) would not contain the value 5, because the next value to add would have been 6 instead of 5.

Examples

ISEQ 5 10 Result: [5 6 7 8 9 10] ISEQ 10 5 Result: [10 9 8 7 6 5] (ISEQ 5 10 2) Result: [5 7 9]


ITEM

Returns a specific element of its input; two inputs.

Syntax

ITEM number word
ITEM number list

Description

ITEM reports the nth element from the second input where n is the first input (1), an integer, and the second input is a number, word, or list.

Examples

ITEM 3 “CAT Result: T ITEM 2 753 Result: 5 ITEM 3 [IN AT ON] Result: ON


JOIN

Converts a list to a word; two inputs.

Syntax

JOIN list separator

Description

JOIN concatenates each element of the list it receives as its first input and inserts the separator given as the second input between each list element. It reports the resulting word.

Use SPLIT to convert a JOINed word into a list.

Examples

JOIN [A B C D E] “| is | Result: A is B is C is D is E SPLIT “A,B,C,D,E “, Result: [A B C D E]


LAST

Reports the last element of its input; one input.

Syntax

LAST word
LAST list

Description

LAST reports the last element of its input. If the input is a word, LAST reports the last character. If the input is a list, LAST reports the last element of that list. If the word or list is empty, there is no last element, and LAST throws an error. See also BUTFIRST, BUTLAST, and FIRST.

Examples

LAST [MARY HAD A LITTLE LAMB] Result: LAMB LAST “WHEAT Result: T LAST 2135 Result: 5


LIST

Concatenates its inputs to a list; expects a minimum of one input, but parentheses are needed if not called with two inputs.

Syntax

LIST object1 object2
(LIST object1 object2 object3 ...)

Description

LIST reports a list composed of its inputs. The inputs to LIST can be either words or lists. If the inputs to LIST are themselves lists, LIST preserves them as lists. LIST expects two inputs, but can accept more or fewer if it and all its inputs are enclosed in parentheses. See also FPUT, LPUT, SENTENCE, and WORD.

To create a list enclosed in parentheses, use the XLIST command.

Examples

LIST “NORTH “CAROLINA Result: [NORTH CAROLINA] LIST [TO BE] [OR NOT TO BE] Result: [[TO BE] [OR NOT TO BE]]


LOCAL

Declares local variables inside a procedure; expects a minimum of one input, but parentheses are needed if not called with one input.

Syntax

LOCAL name
(LOCAL name1 name2 ...)

Description

LOCAL defines its input as a local variable whose value affects only the procedure in which it is called. The variable’s previous value (if any) is saved at the beginning of the procedure where it is redefined and restored at the end of the procedure. The variable is only available within the procedure in which it is defined and in all other procedures that are called from within the procedure where the variable is defined. The inputs to LOCAL must be quoted words.

Initially, a local name does not have a value. An attempt to read from a freshly declared local name causes a runtime error.


LOCALMAKE

Also: LMAKE

Create and set a local name; two inputs.

Syntax

LMAKE varname value

Description

LMAKE works in two ways. The first time LMAKE varname value is used in a procedure, Logo creates a new local name varname and assigns value to the local varname. This is the same as [LOCAL](cmd:LOCAL) varname MAKE varname value. For all subsequent uses of LMAKE varname value, Logo just uses the existing local varname. This is the same as MAKE varname value. The important thing to consider about LMAKE is that it ensures that the variable being referenced is local (by either creating a new local variable or using an existing local variable).

See also LOCAL, MAKE and THING.

Examples

MAKE “X “TOP TO TESTX LMAKE “X “INSIDE OUTPUT :X END TESTX defined TESTX Result: INSIDE :X Result: TOP


LOWERCASE

Converts its argument to lower case; one input.

Syntax

LOWERCASE word

Description

LOWERCASE converts its input to lower case. See also MIXEDCASE and UPPERCASE.

Examples

LOWERCASE “HELLO Result: hello LOWERCASE “|Hello| Result: hello


LPUT

Appends an element to its input; two inputs.

Syntax

LPUT word word
LPUT word list
LPUT list list

Description

LPUT reports a new object that is created by placing the first input at the end of the second input. The inputs to LPUT can be either words or lists. If the first input is a list, the second cannot be a word. If both inputs are words, LPUT reports a word. See also LIST, FPUT, SENTENCE, and WORD.

Examples

LPUT “ISSIPPI “MISS Result: MISSISSIPPI LPUT [COLORADO] [MISS] Result: [MISS [COLORADO]] LPUT FIRST [X Y Z] [A B C D] Result: [A B C D X]


MAKE

Assigns a value to a name; two inputs.

Syntax

MAKE name data

Description

MAKE defines a variable using the name of the first input and assigns the second input as the value of that variable. Once you have created the variable, you may obtain its contents by using :name. Think of the colon (:) as the value of name. To keep a variable local to the procedure in which MAKE is used, see LOCAL or LMAKE.

Remember that all local names of a procedure are visible to any procedure; a MAKE command may, therefore, set a name that is local to a procedure that is calling the current procedure if you use MAKE inside a procedure. See also NAME and THING.

Examples

MAKE “NUMBER 73 :NUMBER Result: 73


MILLISECONDS

Outputs the number of milliseconds spent; no inputs.

Syntax

MILLISECONDS

Description

MILLISECONDS outputs the number of milliseconds spent since the document loaded. MILLISECONDS can be used to track execution times. The accuracy of this timer is supposed to be at least 5 microseconds, but depends on the browser and operating system. Also, it is not guaranteed that the timer started running when the document has been loaded.


MIXEDCASE

Converts its argument to mixed case; one input.

Syntax

MIXEDCASE word

Description

MIXEDCASE converts its input to mixed case. Every word of its input starts with an upper case letter, while the remainder of the word is lower case. See also LOWERCASE and UPPERCASE.

Examples

MIXEDCASE “HELLO Result: Hello MIXEDCASE “|hello world| Result: Hello World


NAME

Assigns a value to a name; two inputs.

Syntax

NAME data name

Description

NAME defines a variable by assigning the value of the first input to the name of the second input. Once you have created the variable, you may obtain its contents by using :name. Think of the colon (:) as the value of name. NAME is equivalent to MAKE except that inputs are in reverse order. See also LOCAL.

Examples

NAME 5 “FIVE :FIVE Result: 5


PARSE

Parses a string and outputs a list; one input.

Syntax

PARSE word

Description

PARSE reads its input and converts it to a list.

The Listener procedure that Logo uses to evaluate user input is roughly written as:

TO LISTENER<br>RUN [PARSE READQUOTE]<br>END

Examples

PARSE “|hi world| Result: [HI WORLD] PARSE “|(a b c)| Result: [(A B C)]


PICK

Randomly picks an element; one input.

Syntax

PICK object

Description

PICK picks a randomly selected element from its input, a word or list.

Examples

MAKE “MUSIC [JAZZ POP ROCK CLASSICAL] PICK :MUSIC Result: POP PICK :MUSIC Result: CLASSICAL PICK “ABCDE Result: D PICK “ABCDE Result: B


QUOTE

Quotes its input; one input.

Syntax

QUOTE word

Description

QUOTE quotes its input. Lists are returned unchanged.

Examples

MAKE “FIRSTNAME “JOHN :FIRSTNAME Result: JOHN QUOTE :FIRSTNAME Result: “JOHN


RSEQ

Outputs a list of equally spaced rational numbers; three inputs.

Syntax

RSEQ from to count

Description

RSEQ outputs a list of “count” equally spaced rational numbers between “from” and “to”, inclusive.

Examples

RSEQ 4 5 6 Result: [4 4.2 4.4 4.6 4.8 5]


SENTENCE

Also: SE

Concatenates its inputs to a list, flattening lists; expects a minimum of one input, but parentheses are needed if not called with two inputs.

Syntax

SENTENCE object1 object2
(SE object1 object2 object3 ...)

Description

SENTENCE reports a list made up of its inputs. SENTENCE expects two inputs, but will accept more if it and all of its inputs are enclosed in parentheses. If the inputs to SENTENCE are lists, their brackets are removed and combined into one list. See also FPUT, LPUT, LIST, and WORD.

Examples

SENTENCE “NICEST “MONTH Result: [NICEST MONTH] SENTENCE [APRIL IS THE][NICEST MONTH] Result: [APRIL IS THE NICEST MONTH]


SPLIT

Splits a word into a list using a separator; two inputs.

Syntax

SPLIT word separator

Description

SPLIT uses the separator character(s) given as its second input to split a word into a list of words. Use JOIN to convert such a list back to a word.

Examples

SPLIT “A,B,C,D,E “, Result: [A B C D E] JOIN [A B C D E] “| is | Result: A is B is C is D is E


SUBST

Substitutes text in a word or a list; three inputs.

Syntax

SUBST what with wordorlist

Description

SUBST performs a replacement of text in its arguments. It replaces all occurrences of its first input with its second input inside the word or list given as its third input. If the third input is a list, the replacement is recursive and affects all lists inside the list. If the list element to be replaced is quoted, the replaced text remains quoted. In the same way, leading colons are preserved.

Examples

; Quotes and colons are preserved. SUBST “JUNK “NEW [A JUNK BOX] Result: [A NEW BOX] SUBST “? “X “A?B?C Result: AXBXC SUBST “? “MIKE [HELLO ? [HOW ARE YOU ?]] Result: [HELLO MIKE [HOW ARE YOU MIKE]]


THING

Reports the value of a name; one input.

Syntax

THING word

Description

THING reports the value associated with the variable named in the input. THING is the Logo primitive that does the same job as : (dots). It can be used to give a variable a second level of evaluation. A variable name could, for example, be passed to a procedure, and the procedure obtains its value with the THING command. Remember that Logo makes all names in a procedure visible to a procedure that this procedure calls. Therefore, getting a value may result in getting the value of a name that is local to a calling procedure.

Examples

MAKE “COLOR “BLUE MAKE “BLUE “AQUAMARINE THING “COLOR Result: BLUE THING :COLOR Result: AQUAMARINE THING “BLUE Result: AQUAMARINE THING :BLUE Result: :AQUAMARINE is not a name


TIME

Outputs the time; no inputs.

Syntax

TIME

Description

TIME reports the current time as a list of three numbers in the form [hour minute second]. The hours are in 24-hour format. See also DATE.

Examples

TIME Result: [10 35 50]


UPPERCASE

Converts its argument to upper case; one input.

Syntax

UPPERCASE word

Description

UPPERCASE converts its input to upper case. See also LOWERCASE and MIXEDCASE.

Examples

PR UPPERCASE “HELLO Result: HELLO PR UPPERCASE “|hello world| Result: HELLO WORLD


VERINFO

Outputs Logo version information as a list; no inputs.

Syntax

VERINFO

Description

VERINFO reports information about the version of Logo that is currently running as a list. The elements are major version number, minor version number, subrelease number, the name of the Logo program, the build date as a string, and the name of the operating system.

Examples

VERINFO Result: [6 0 252490 Terrapin Logo 2025/09/06 08:44:46 Windows WEB]


VERSION

Also: VER

Outputs the Logo version; no inputs.

Syntax

VERSION

Description

VERSION reports information about the version of Logo that is currently running.

Examples

VERSION Result: Terrapin Logo Windows (Web) Logo 6.0.252490 2025/09/06 08:44:46 Help 6.0.252490


WORD

Concatenates its inputs to a word; expects a minimum of one input, but parentheses are needed if not called with two inputs.

Syntax

WORD object1 object2
(WORD object1 object2 object3 ...)

Description

WORD concatenates its inputs, which must not be lists, to a single word.

Examples

WORD “NICEST “MONTH Result: NICESTMONTH


XLIST

Concatenates its inputs to a parenthesized list; expects between one input and two inputs, but parentheses are needed if not called with two inputs.

Syntax

XLIST object1 object2
(XLIST object1 object2 object3 ...)

Description

XLIST reports an executable list composed of its inputs. The inputs to XLIST can be either words or lists. If the inputs to XLIST are themselves lists, XLIST preserves them as lists. XLIST expects two inputs, but can accept more or fewer if it and all its inputs are enclosed in parentheses.

An executable list is a list enclosed in parentheses. To create a normal list, use the LIST command.

Examples

; This example creates a runlist containing a SENTENCE ; command with three instead of two inputs. This commands needs to be ;enclosed in parentheses so Logo can pick up all inputs. (LIST (XLIST “SENTENCE 1 2 3)) Result: [(SENTENCE 1 2 3)] RUN (LIST (XLIST “SENTENCE 1 2 3)) Result: [1 2 3]