(defun tree-beam-search (start goal-p successors cost-fn beam-width) (tree-search (list start) goal-p successors (lambda (old new) (let ((sorted (funcall (sorter cost-fn) old new))) (if (> beam-width (length sorted)) sorted (subseq sorted 0 beam-width))))))Source Context