Skip to content

Commit

Permalink
There were a few more 'gmap' forms in the old syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
slburson committed May 31, 2024
1 parent e06218d commit f21a445
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
31 changes: 16 additions & 15 deletions Code/relations.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,14 @@ constructed."

(defun 2-relation-fn-compose (rel fn)
(let ((new-size 0)
((new-map0 (gmap :wb-map (lambda (x ys)
(let ((result nil))
(Do-WB-Set-Tree-Members (y ys)
(setq result (WB-Set-Tree-With result (@ fn y))))
(incf new-size (WB-Set-Tree-Size result))
(values x result)))
(:wb-map (make-wb-map (wb-2-relation-map0 rel)))))))
((new-map0 (gmap (:result wb-map)
(fn (x ys)
(let ((result nil))
(Do-WB-Set-Tree-Members (y ys)
(setq result (WB-Set-Tree-With result (@ fn y))))
(incf new-size (WB-Set-Tree-Size result))
(values x result)))
(:arg wb-map (make-wb-map (wb-2-relation-map0 rel)))))))
(make-wb-2-relation new-size
(wb-map-contents new-map0)
nil)))
Expand Down Expand Up @@ -637,22 +638,22 @@ contains the pairs <1, a>, <1, b>, <2, a>, and <2, b>."
(recur (cdr subforms)
`(union ,result
(let ((,vals-var ,(cadadr subform)))
(gmap :union
(gmap (:result union)
(fn (,key-var)
(convert ',type-name
(map (,key-var ,vals-var))
:from-type 'map-to-sets))
(:set ,(cadar subform))))))))
(:arg set ,(cadar subform))))))))
((and (listp (car subform)) (eq (caar subform) '$))
(let ((key-var (gensym "KEY-"))
(val-var (gensym "VAL-")))
(recur (cdr subforms)
`(union ,result
(let ((,val-var ,(cadr subform)))
(gmap :union
(gmap (:result union)
(fn (,key-var)
(,type-name (,key-var ,val-var)))
(:set ,(cadar subform))))))))
(:arg set ,(cadar subform))))))))
((and (listp (cadr subform)) (eq (caadr subform) '$))
(recur (cdr subforms)
`(union ,result
Expand Down Expand Up @@ -799,9 +800,9 @@ pattern."))
(gmap (:result list :filterp #'identity)
(fn (index i pat-elt)
(and (logbitp i mask)
(gmap :union
(gmap (:result union)
(fn (pat-elt-elt) (@ index (list pat-elt-elt)))
(:set pat-elt))))
(:arg set pat-elt))))
(:arg list (get-indices rel mask))
(:arg index 0)
(:arg list pattern))))
Expand Down Expand Up @@ -863,8 +864,8 @@ considered as a bit set."
(:arg list unindexed)
(:arg index 0))
(setf (wb-list-relation-indices rel) indices))
(gmap :list (lambda (ex-ind new-index)
(or ex-ind new-index))
(gmap (:result list) (fn (ex-ind new-index)
(or ex-ind new-index))
(:list ex-inds)
(:vector new-indices))))))

Expand Down
8 changes: 4 additions & 4 deletions Code/testing.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,14 @@
(test (equal (multiple-value-list (lookup (convert 'bag '(3 3 5 5 5)) 4)) '(nil nil)))

(dolist (n '(2 5 10 20))
(let* ((s (gmap :set (fn (i) (make-instance 'my-unhandled-obj :value i)) (:index 0 n)))
(singles (gmap :list (fn (o) (set o)) (:set s))))
(let* ((s (gmap (:result set) (fn (i) (make-instance 'my-unhandled-obj :value i)) (:arg index 0 n)))
(singles (gmap (:result list) (fn (o) (set o)) (:arg set s))))
(dolist (s1 singles)
(test (subset? s1 s))
(test (not (subset? s s1))))
(test (every (lambda (o) (lookup s o)) s))))

(let* ((objs (gmap :list (fn (i) (make-instance 'my-unhandled-obj :value i)) (:index 0 3)))
(let* ((objs (gmap (:result list) (fn (i) (make-instance 'my-unhandled-obj :value i)) (:arg index 0 3)))
(s (convert 'set objs))
(s1 (set (car objs)))
(s2 (set (cadr objs)))
Expand Down Expand Up @@ -387,7 +387,7 @@
(simple-type-error (e) e)))

(dolist (n '(0 2 5 7 10))
(let* ((vals (gmap :list nil (:index 0 n)))
(let* ((vals (gmap (:result list) nil (:arg index 0 n)))
#+sbcl
(seq (make-instance 'my-sequence :actual vals))
(s (set)))
Expand Down

0 comments on commit f21a445

Please sign in to comment.