14. Multiple returns

If your goal is to return multiple values from a function, you can use values:

(defun tabla (n)
  (values n (* n 2) (* n 3)))

We will return a tuple with the number, its double, and its triple.

* (tabla 5)
(5 10 15)

It is not a list, but multiple returned values.

* (multiple-value-list (tabla 5))
(5 10 15)

* (nth-value 1 (tabla 5))
10

* (first (multiple-value-list (tabla 5)))
5

* (car (last (multiple-value-list (tabla 5))))
15
Building SPAs with Django and HTML Over the Wire: Learn to build real-time single page applications with Python

Building SPAs with Django and HTML Over the Wire: Learn to build real-time single page applications with Python

The HTML over WebSockets approach simplifies single-page application (SPA) development and lets you bypass learning a JavaScript rendering framework such as React, Vue, or Angular, moving the logic to Python. This web application development book provides you with all the Django tools you need to simplify your developments with real-time results.

Buy the book

Help me keep writing

Every coffee gives me a push toward the next article.

Comments

There are no comments yet.