In lisp, how do I use the second value returned by the gender function?

When I (floor 4 3) I got

1 1/3 

But how can I use this 1/3?

+5
source share
1 answer

You can, for example, bind it to a variable using multiple-value-bind .

 (multiple-value-bind (quot rem) (floor 4 3) (format t "The remainder is ~f~%" rem)) 

Another possibility, if you are only interested in one non-primary value, is nth-value .

 (format t "The remainder is also ~f~%" (nth-value 1 (floor 4 3))) 

For reference, see Hyperspec .

+17
source

Source: https://habr.com/ru/post/977633/


All Articles