Home / Uncategorized / Some notes working with Common Lisp

Some notes working with Common Lisp

Print Friendly, PDF & Email

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.

comments

About 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.