Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multiple-value-bind discard first value

Tags:

common-lisp

In my code below , I only want r.

(let* ((frac  (multiple-value-bind (f r)  (floor amt  100) r)))
..use frac..)

I get compilation warnings saying unused variable f.

Is there an idiomatic way of writing this?

like image 861
RAbraham Avatar asked Apr 26 '14 23:04

RAbraham


2 Answers

declare ignore is generally useful in this context, here:

(multiple-value-bind (_ frac)  (floor amt 100)
  (declare (ignore _))
  ; use frac)
like image 182
uselpa Avatar answered Sep 30 '22 20:09

uselpa


NTH-VALUE allows you to choose one of a form's return values. This will behave like your snippet:

(let* ((frac (nth-value 1 (floor amt 100))))
  ...)
like image 44
m-n Avatar answered Sep 30 '22 20:09

m-n