Terrapin Resources

Terrapin Logo 4 has been discontinued! Our new Terrapin Logo version is much more powerful and modern; we strongly recommend that you update to our latest release of the Logo programming language.

Putting things together

This section contains all commands that put together Logo words or lists, or access elements of Logo words or lists.

FPUT

Prepends an element to its input.

Syntax

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.

Example

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]

ISEQ

Outputs a list of sequential integers.

Syntax

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.

Example

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]

LIST

Concatenates its inputs to a list.

Syntax

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 less if it and all its inputs are enclosed in parentheses. See also FPUT, LPUT, SENTENCE, and WORD.

Example

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

LPUT

Appends an element to its input.

Syntax

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.

Example

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]

PARSE

Parses a string and outputs a list.

Syntax

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:

Example

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

RSEQ

Outputs a list of equally spaced rational numbers.

Syntax

Description

RSEQ outputs a list of COUNT equally spaced rational numbers between FROM and TO, inclusive.

Example

RSEQ 4 5 6 Result: [4 4.17 4.33 4.5 4.67 4.83]

SENTENCE

Also: SE

Concatenates its inputs to a list, flattening lists.

Syntax

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.

Example

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

SUBST

Substitutes text in a word or a list.

Syntax

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.

Example

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]]

WORD

Concatenates its inputs to a word.

Syntax

Description

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

Example

WORD “NICEST “MONTH Result: NICESTMONTH