Some notes working with Common Lisp

1. When using multiple-value-bind, there are some values that we don’t need. We can ignore the warning « The variable x, y,… is never used… ». Below is an example:
(defun my-round (x)
(round (+ x 0.5)))

(defun next-power-of-two (x)
(let ((log-base2 (/ (log x) (log 2))))
(multiple-value-bind (y z)
(my-round (expt 2 (ceiling log-base2)))
(declare (ignorable z))
y)))
Because the my-round functions returns two values, but I only use the first one. When I apply this function inside the next-power-of-two function, I also need the first.

2. In order to use the hexadecimal values in Common Lisp, we can use « #x » or « x16r » to represent them.

Nguyen Vu Ngoc Tung

I love making new professional acquaintances. Don't hesitate to contact me via nguyenvungoctung@gmail.com if you want to talk about information technology, education, and research on complex networks analysis (i.e., metabolic networks analysis), data analysis, and applications of graph theory. Specialties: researching and proposing innovative business approaches to organizations, evaluating and consulting about usability engineering, training and employee development, web technologies, software architecture.

https://www.itersdesktop.com/author/nvntung/

2 thoughts on “Some notes working with Common Lisp

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Ce site utilise Akismet pour réduire les indésirables. En savoir plus sur la façon dont les données de vos commentaires sont traitées.