Command List
These are commands that affect strings.
butfirst (bf)
value
Parameters:
value |
List or string |
A list of data or a string |
Description:
When passed a list,
butfirst
returns a new list
[list of data]
with the first item removed. The input list is not changed.
When passed a string, butfirst
returns a new string with the first character removed. The input string is not changed.
Examples:
butfirst [4 5 6 7]
returns [5 6 7]
.
Related Commands:
butlast
first
last
lput
sentence
butlast (bl)
value
Parameters:
value |
List or string |
The list of data or string to operate on |
Description:
When given a list of data, returns the new value of value with the last item removed. The input list is not changed.
When given a string, returns a new string with the last character removed. The input string is not changed.
Examples:
butlast [4 5 6 7]
returns [4 5 6]
.
Related Commands:
butfirst
first
last
lput
sentence
empty?
data
Parameters:
data |
List or string |
list or string to test for emptiness |
Description:
If
data is a list of data, reports true if
data is empty.
If data is a string, reports true if data has no characters (i.e. = "").
Examples:
empty? [0 0]
returns false.
empty? [] returns true.
empty? "hello" returns false.
Related Commands:
first
last
make-list
sentence
first
[list of data] or string
Parameters:
[list of data] or string |
List or string |
List or string to return the first character/element from |
Description:
Returns the first element of a [list of data] or the first character of a string.
Examples:
first [3 4 5 6]
returns 3.
first "hello" returns "h".
Related Commands:
butfirst
butlast
empty?
fput
last
lput
fput
item
Parameters:
Description:
Adds the item into the list as the first element
Examples:
fput 1 [2 3 4]
returns [1 2 3 4].
fput "hello" "mom"
returns "hellomom".
Related Commands:
first
insert
last
lput
reverse
sentence
item
number [list]
Parameters:
number |
Number |
|
[list] |
List |
|
Description:
Returns the element of [list] at the number'th position.
Examples:
item 2 [4 6 8]
returns 6.
Notes:
Indexing starts from 1.
Related Commands:
position
remove
remove-element
setitem
last
[list of data]
Parameters:
[list of data] |
List or string |
list of data of which you want the last element |
Description:
Returns the last item of [list of data].
Examples:
last [4 5 6 7]
returns 7.
Related Commands:
butfirst
butlast
empty?
first
fput
lput
length
[list of data]
Parameters:
[list of data] |
List or string |
list of data for which you want the length |
Description:
Returns the length of [list of data].
Examples:
length []
returns 0.
length [4 5 6 7]
returns 4.
Related Commands:
list
make-list
sentence
lput
item [list of data]
Parameters:
item |
Integer |
the item that you are placing in the list |
[list of data] |
List or string |
list of data that you are adding to |
Description:
Returns the new value of [list of data] with item as its last element. The input list is not changed.
Examples:
lput 4 [1 2 3]
returns [1 2 3 4]
.
Related Commands:
butfirst
butlast
first
fput
insert
last
reverse
sentence
member?
item [list of data]
Parameters:
item |
Anything |
item which you are looking for |
[list of data] |
List or string |
list of data to search |
Description:
Returns true if item is a member of [list of data].
Examples:
member? 4 [1 0 9]
returns false
.
member? 4 [1 4 9]
returns true
.
Related Commands:
insert
position
remove
remove-element
setitem
reverse
[list]
Parameters:
[list] |
List |
list to be reversed |
Description:
Reports the new list with the order of the elements in [list] reversed. The input [list] is not changed.
Examples:
reverse [1 2 3]
reports the list [3 2 1].
Related Commands:
fput
list
lput
sentence
to-string
[list of commands]
Parameters:
[list of commands] |
List of commands |
Commands to execute whose return values will form the string |
Description:
Takes a list of instructions (variables, reporters, strings), executes them, and concatenates their return values, returning the concatenated string.
Related Commands:
to-delimited-string
to-list
word?
thing
Parameters:
Description:
Returns true if thing is a word or string.
Examples:
word? 2
returns true
word? [1 2 3]
returns false
Notes:
See the Data Types documentation for what constitutes a word or string.
Related Commands:
list?
number?