Hi,

I was optimizing my code and noticed that I got a bunch of brute force
searches for an extremum of a function of more then one value like so:

(bind (((best-x best-y best-z)
  (iter outer
    (for x ...)
      (iter (for y ...)
        (iter (for z ...)
           (in outer
             (finding (list x y z) maximizing (objective x y z))))))))
  ...)

The above code is causing excessive consing in the (list x y z) part
and one can't specify (values) instead.

With the attached patch I can write:

(bind (((values best-x best-y best-z)
  (iter outer
    (for x ...)
      (iter (for y ...)
        (iter (for z ...)
           (in outer
             (finding (values x y z) maximizing (objective x y z))))))
  ...)

which does not cons and results in faster code. 

Attachment: finding-values.patch
Description: Binary data

Regards,
  Max
  
             
  

   
           
_______________________________________________
iterate-devel site list
iterate-devel@common-lisp.net
http://common-lisp.net/mailman/listinfo/iterate-devel

Reply via email to