Hi,
I have a list of numbers, and I want to calculate all their extents
and find the widest (using a function called text-extents, which
returns four values).
I tried it like this:
(defun measure-axis-numbers (axis-numbers)
(iter
(for x in axis-numbers)
(multiple-value-bind (x-bearing y-bearing width height)
(text-extents x)
(collect (list x x-bearing y-bearing width height))
(finding width maximizing width))))
There is a problem in the last part with finding, how can I make it
work?
Thanks,
Tamas
Tamas Papp wrote:
[...]
> I tried it like this:
> (defun measure-axis-numbers (axis-numbers)
> (iter
> (for x in axis-numbers)
> (multiple-value-bind (x-bearing y-bearing width height)
> (text-extents x)
> (collect (list x x-bearing y-bearing width height))
> (finding width maximizing width))))
> There is a problem in the last part with finding, how can I make it
> work?
You're trying to do two things and obtain two values, but as written,
the ITER form only returns one value and only sets up a single binding
for the results of both the COLLECT and FINDING clauses. Use :INTO
with each, and then do (finally (return (values ...))).
Also, you can do VALUES destructuring with FOR clauses, like this:
(for (values x-bearing y-bearing width height) := (text-extents x))
It's a little terser and looks more pleasingly ITERATEy.
Cheers,
Pillsy