Hi,
I'm looking for CL code to compute a convex hull in 2D. Has anyone
put together such a function? I couldn't find mention of it in the
CMU repository. I'd be grateful for any pointers.
Thanks,
Rob St. Amant
--
Robert St. Amant Email: ·······@csc.ncsu.edu
Computer Science Department Voice: (919) 515-7938
North Carolina State University Fax: (919) 515-7925
Sam Steingold <···@usa.net> writes:
> the [xy]keys should be
> "funcallable", i.e., be function or symbol. How do I declare them?
Heh. FWIW, I think this is legal:
(declare (type (or function symbol) xkey ykey))
On the other hand, you're not likely to get a big speed jump out of
an OR type declaration. If you truly care, try:
(defun foo ... (... xkey ykey)
(let ((xkey (etypecase xkey
(symbol (symbol-function xkey))
(function xkey)))
(ykey (etypecase ykey
(symbol (symbol-function ykey))
(function ykey))))
(declare (type function xkey ykey))
...))
That might get you a boost in some implementations since there's a
realistic chance someeon open-codes just function where they'd likely
not open-code the check-for-symbol-function situation.
Sam Steingold <···@usa.net> writes:
> [In a DECLARE] Why do you write (type function xkey ykey) instead of just
> (function xkey ykey)?
I dunno--just sometimes it seems like the thing to do.
For emphasis, I guess.
Kent M Pitman wrote:
> Sam Steingold <···@usa.net> writes:
>
> > [In a DECLARE] Why do you write (type function xkey ykey) instead of just
> > (function xkey ykey)?
>
> I dunno--just sometimes it seems like the thing to do.
> For emphasis, I guess.
Here's one good reason (chuckle):
> (pprint '(defun foo (x)
(declare (function x))
(funcall x 3)))
(DEFUN FOO (X) (DECLARE #'X) (FUNCALL X 3))
> (pprint '(defun foo (x)
(declare (type function x))
(funcall x 3)))
(DEFUN FOO (X) (DECLARE (TYPE FUNCTION X)) (FUNCALL X 3))