golems / motion-grammar-kit

Formal Language Tools for Robots
BSD 2-Clause "Simplified" License
13 stars 5 forks source link

Implementation of fold-fa-edges #5

Closed Tarrasch closed 11 years ago

Tarrasch commented 11 years ago

I'm not sure how to use fold-fa-edges. I thought it would be something like (fold-fa-edges (lambda (acc edge) (+ c (cadr edge))) 0 my-fa), but that doesn't work for me. Might the implementation be wrong?

I changed

(defun fold-fa-edges (function initial-value fa)
  (fold (lambda (v e) (apply function v e))
        initial-value (fa-edges fa)))

to

(defun fold-fa-edges (function initial-value fa)
  (fold function
        initial-value (fa-edges fa)))

and then I got the behavior I expected.

Tarrasch commented 11 years ago

Hmm on second thoughts there is usage in the code where lambda is like (lambda (acc start-node edge-value end-node)) which makes at least as much sense. perhaps a line of documentation could be in order?

ndantam commented 11 years ago

3fd4c61