add transducers, some small refactors

This commit is contained in:
Peter Tillemans 2024-12-08 22:15:56 +01:00
parent f7bda050dd
commit 9dbbe1df62
3 changed files with 3 additions and 1 deletions

View file

@ -18,6 +18,7 @@
#:queues.simple-queue #:queues.simple-queue
#:bt-semaphore ; threads higher level lib #:bt-semaphore ; threads higher level lib
#:trivia ; community standard pattern matching #:trivia ; community standard pattern matching
#:transducers
) )
:components ((:module "src" :components ((:module "src"
:components :components

View file

@ -115,6 +115,7 @@
(defun guard-path (labo guard &optional (path (make-hash-table :size 10000)) (extra-block nil)) (defun guard-path (labo guard &optional (path (make-hash-table :size 10000)) (extra-block nil))
(let ((hash (guard-hash guard))) (let ((hash (guard-hash guard)))
(format t "~A~%" guard)
(cond (cond
((not guard) (remove-duplicates (loop for k being the hash-keys of path collect (floor (/ k 10))))) ((not guard) (remove-duplicates (loop for k being the hash-keys of path collect (floor (/ k 10)))))
((gethash hash path) nil) ((gethash hash path) nil)

View file

@ -54,7 +54,7 @@
"returns simplified equation after applying the * operator or nil if not possible" "returns simplified equation after applying the * operator or nil if not possible"
(let ((r (equation-result equation)) (let ((r (equation-result equation))
(os (equation-operands equation))) (os (equation-operands equation)))
(and (= (gcd r (first os)) (first os)) (and (zerop (mod r (first os)))
(make-equation :result (/ r (first os)) :operands (cdr os))))) (make-equation :result (/ r (first os)) :operands (cdr os)))))
(defun plus-branch (equation) (defun plus-branch (equation)