Category talk:Wren-seq: Difference between revisions

Content added Content deleted
(→‎Source code: Added Lst.exchange method.)
(→‎Source code: Some fairly minor adjustments to the Stack class.)
Line 67:
var count = a.count
var indices = []
if (count == 0) return [false, 0, indices]
if (start < 0) start = count + start
for (i in start...count) {
Line 385:
// Returns the number of elements in the stack.
count { _stack.count }
 
// Returns whether or not the stack is empty.
isEmpty { count == 0 }
 
// Removes all elements from the stack.
Line 390 ⟶ 393:
 
// Returns the last item on the stack without removing it.
// Returns null if the stack is empty.
peek() { (!isEmpty) ? _stack[-1] : null }
 
Line 395 ⟶ 399:
push(item) { _stack.add(item) }
 
// Adds a sequence of 'items' (in order) to the stack and returns them.
pushAll(items) { _stack.addAll(items) }
 
// Removes the last item from the stack and returns it.
// Returns null if the stack is empty.
pop() {
var item = peek()
Line 409 ⟶ 414:
// Clones the stack.
clone() {
var ns = Stack.new()
ns.pushAll(Lst.clone(_stack))
return ns
}