LispPad
  • Home
  • Applications
    • 🖥️LispPad
      • Sessions
      • Editor
      • Preferences
    • 📱LispPad Go
    • 📜Language
    • 📖Libraries
  • Libraries
    • ⚙️LispKit
      • (lispkit archive tar)
      • (lispkit archive zip)
      • (lispkit base)
      • (lispkit bitset)
      • (lispkit box)
      • (lispkit bytevector)
      • (lispkit char)
      • (lispkit char-set)
      • (lispkit combinator)
      • (lispkit comparator)
      • (lispkit control)
      • (lispkit core)
      • (lispkit crypto)
      • (lispkit csv)
      • (lispkit datatype)
      • (lispkit date-time)
      • (lispkit debug)
      • (lispkit disjoint-set)
      • (lispkit draw)
      • (lispkit draw turtle)
      • (lispkit draw barcode)
      • (lispkit draw chart bar)
      • (lispkit dynamic)
      • (lispkit enum)
      • (lispkit format)
      • (lispkit graph)
      • (lispkit gvector)
      • (lispkit hashtable)
      • (lispkit heap)
      • (lispkit http)
      • (lispkit http oauth)
      • (lispkit http server)
      • (lispkit iterate)
      • (lispkit json)
      • (lispkit json schema)
      • (lispkit list)
      • (lispkit list set)
      • (lispkit log)
      • (lispkit markdown)
      • (lispkit match)
      • (lispkit math)
      • (lispkit math matrix)
      • (lispkit math stats)
      • (lispkit math util)
      • (lispkit object)
      • (lispkit port)
      • (lispkit prolog)
      • (lispkit queue)
      • (lispkit record)
      • (lispkit regexp)
      • (lispkit serialize)
      • (lispkit set)
      • (lispkit sqlite)
      • (lispkit stack)
      • (lispkit stream)
      • (lispkit string)
      • (lispkit styled-text)
      • (lispkit system)
      • (lispkit system call)
      • (lispkit system keychain)
      • (lispkit system pasteboard)
      • (lispkit test)
      • (lispkit text-table)
      • (lispkit thread)
      • (lispkit thread channel)
      • (lispkit-thread-future)
      • (lispkit thread shared-queue)
      • (lispkit type)
      • (lispkit url)
      • (lispkit vector)
    • ⚙️LispPad
      • (lisppad applescript)
      • (lisppad draw map)
      • (lisppad location)
      • (lisppad speech)
      • (lisppad system)
      • (lisppad turtle)
    • ⚙️SRFI
  • Examples
    • 📝LispKit
    • 📝LispPad
    • 📝LispPad Go
  • Releases
    • 🖥️LispPad
    • 📱LispPad Go
  • Downloads
  • Privacy Policy
  • Contact
Powered by GitBook
On this page
  1. Libraries
  2. LispKit

(lispkit stack)

Last updated 6 months ago

Library (lispkit stack) provides an implementation for mutable stacks, i.e. mutable LIFO buffers.

stack-type-tag

Symbol representing the stack type. The type-for procedure of library (lispkit type) returns this symbol for all stack objects.

(make-stack)

Returns a new empty stack.

(stack x ...)

Returns a new stack with x on its top position followed by the remaining parameters.

(stack-top (stack 1 2 3))  ⇒ 1 

(stack? obj)

Returns #t if obj is a stack; otherwise #f is returned.

(stack-empty? s)

Returns #t if stack s is empty.

(stack-size s)

Returns the size of stack s, i.e. the number of elements buffered in s.

(stack=? s1 s2)

Returns #t if stack s1 has the exact same elements in the same order like stack s2; otherwise, #f is returned.

(stack-push! s x)

Pushes element x onto stack s.

Returns the top element of stack s. If the stack is empty, an error is raised.

Removes the top element from stack s and returns its value.

(define s (make-stack))
(stack-push! s 1)
(stack-push! s 2)
(stack-pop! s)  ⇒ 2
(stack-size s)  ⇒ 1

Removes all elements from stack s.

Returns a copy of stack s.

Returns a list consisting of all elements on stack s in the order they appear, i.e. starting with the top element.

(stack->list (stack 1 2 3))

Returns a new stack consisting of the elements of list l. The first element in l will become the top element of the stack that is returned.

Pushes the elements of list l onto stack s in reverse order.

(define s (list->stack '(3 2 1)))
(list->stack! s '(6 5 4))
(stack->list s)  ⇒ (6 5 4 3 2 1)

(stack-top s)

(stack-pop! s)

(stack-clear! s)

(stack-copy s)

(stack->list s)

(list->stack l)

(list->stack! s l)

⚙️