lisp123456

Untitled

Oct 19th, 2021
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. (defun recursive-commutation (path-list)
  2. "Perform recursive commutation on a list"
  3. (flet ((apply-recursive-commutation (path)
  4. (let* ((prefix-form (prefix-form path))
  5. (operator (list (operator prefix-form)))
  6. (second-path (inherited-path (operand-1 prefix-form) path))
  7. (third-path (inherited-path (operand-2 prefix-form) path))
  8. (operand-combinations (safe-path-product (recursive-commutation second-path)
  9. (recursive-commutation third-path))))
  10. (loop for operand-combination in operand-combinations
  11. append (commutation (appended-path operator operand-combination path))))))
  12. (typecase path-list
  13. (list (loop for path in path-list
  14. append (apply-recursive-commutation path)))
  15. (atom (if (listp (prefix-form path-list))
  16. (apply-recursive-commutation path-list)
  17. (inherited-path prefix-form path-list))))))
Advertisement
Add Comment
Please, Sign In to add comment