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.

Accessors

Access data.

BUTFIRST

Also: BF

Reports all but the first element of its input.

Syntax

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.

Example

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.

Syntax

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 plural words that end in the letter S).

Example

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

BUTMEMBER

Also: BM

Removes an element from its input.

Syntax

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.

Example

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

FIRST

Reports the first element of its input.

Syntax

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.

Example

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.

Syntax

Description

FLATTEN takes a list as its input and converts it to a flat list. All sub-lists in the list are appended to that flat list. If FLATTEN is called with an input that is not a list, FLATTEN reports its input.

Example

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

FROMMEMBER

Also: FM

Removes the first part of its input until a pattern is found.

Syntax

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.

Example

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]

ITEM

Returns a specific element of its input.

Syntax

Description

ITEM reports the nth element from the second input where n is the first input, an integer, and the second input is a number, word, or list. See also MEMBER?.

Example

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

LAST

Reports the last element of its input.

Syntax

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.

Example

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

LOWERCASE

Converts its argument to lower case.

Syntax

Description

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

Example

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

MIXEDCASE

Converts its argument to mixed case.

Syntax

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.

Example

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

PICK

Randomly picks an element.

Syntax

Description

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

Example

MAKE “MUSIC [JAZZ POP ROCK CLASSIC] PICK :MUSIC Result: POP PICK :MUSIC Result: CLASSIC

UPPERCASE

Converts its argument to upper case.

Syntax

Description

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

Example

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