Skip to main content

Data Structures

  • Chapter
  • First Online:
Programming Algorithms in Lisp
  • 1214 Accesses

Abstract

The next several chapters will be describing the basic data structures that every programming language provides, their usage, and the most important algorithms relevant to them. And we’ll start with the notion of a data structure and tuples or structs that are the most primitive and essential ones.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 29.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 37.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    Moreover, Python has special syntax for destructuring such tuples: dec, rem = truncate(3.14). However, this is not the optimal way to handle returning the primary and one or more secondary values from a function. Lisp provides a more elegant solution called multiple values: all the necessary values are returned via the values form (values dec rem) and can be retrieved with (multiple-value-bind (dec rem) (truncate 3.14) ...) or (rtl:with ((dec rem (truncate 3.14))) ...). It is more elegant because secondary values may be discarded at will by calling the function in a usual way: (+ 1 (truncate 3.14)) => 4. This is not possible in Python, because you can’t sum a tuple with something.

  2. 2.

    Actually, the complexity here is O(n^2) due to the use of the function member that performs set membership test in O(n), but it’s not essential to the general idea. If uf-disjoint is expected to be called with tens or hundreds of points, the roots structure has to be changed to a hash-set that has a O(1) membership operation.

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2021 Vsevolod Domkin

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Domkin, V. (2021). Data Structures. In: Programming Algorithms in Lisp. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-6428-7_4

Download citation

Publish with us

Policies and ethics