Lists (Printable)
Here are a list of commands that affect lists. Note that these commands are only for dlists. dlists are linked data lists, similar to lists in other versions of Logo. Unlike other Logos, however, StarLogo does not enable you to execute dlists as instructions (that is, there is no run command). You can create a dlist using the list or sentence commands, or by enclosing the literal elements in []'s. No elements inside dlist []'s are evaluated.
bf (butfirst) dlist
[Observer, Turtle]
Returns the value of dlist
with the first item removed.
bl (butlast) dlist
[Observer, Turtle]
Returns the value of dlist
with the last item removed.
empty? dlist
[Observer, Turtle]
Returns true if dlist
is empty.
first dlist
[Observer, Turtle]
Returns the first item of dlist
.
fput item dlist
[Observer, Turtle]
Returns the value of dlist
with item
as its first
element.
item number list
[Observer, Turtle]
Returns the element of list
at the number
'th position.
last dlist
[Observer, Turtle]
Returns the last item of dlist
.
length dlist
[Observer, Turtle]
Returns the length of dlist
.
list item1 item2
[Observer, Turtle]
Returns a new dlist with item1
as its first element, and item2
as its second.
list? thing
[Observer, Turtle]
Returns true if thing
is a list.
lput item dlist
[Observer, Turtle]
Returns the value of dlist
with item
as its last
element.
member? item dlist
[Observer, Turtle]
Returns true if item
is a member of dlist
.
pick list
[Observer, Turtle]
Returns a random element of the list
. Returns false
if the list is empty.
position item dlist
[Observer, Turtle]
Returns the position of item
in the dlist
.
se, sentence anything1 anything2
[Observer, Turtle]
Returns a list. If anything1
and anything2
are lists,
it appends the two lists. If anything1
is a list and anything2
is not, it puts anything2
at the end of the first list. If anything1
is not a list and anything2
is a list, it puts anything1
at the front of the second list. If both anything1
and anything2
are not lists, it creates a new list containing both anything1
and anything2
.
setitem number list elt
[Observer, Turtle]
Sets the element at the number
'th position in list
to elt
word? thing
[Observer, Turtle]
Returns true if thing
is a word or a string.