You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Proposal -distribute --- Distribute a set of objects among different bins; each bin is associated with a predicate function. In other words, an object belongs to a bin, if it satisfies the corresponding bin function.
(defundistribute (data bin-functions)
(let* ((f (lambda (x)
(->> bin-functions
(--some (when (funcall it x)
it))))))
(->> data
(--group-by (funcall f it))
;; First item of the result is the input passed
(cons data))))
(distribute (-iterate (lambda (_) (random10)) (random10) 20)
(list (lambda (x)
(zerop (mod x 4)))
(lambda (x)
(zerop (mod x 2)))))
((82736731621307578120)
((closure (t) (x) (=0 (mod x 4))) 8080)
((closure (t) (x) (=0 (mod x 2))) 26622)
(nil73731137571))
The following thing was implicit in the discussion, but was never openly stated: The resulting subsets are disjoint, and an object can belong to one and only one bin.
There could be cases where we may want a single object to belong to multiple bins.
The following thing was implicit in the discussion, but was never openly stated: The resulting subsets are disjoint, and an object can belong to one and only one bin.
There could be cases where we may want a single object to belong to multiple bins.
If you look at the examples I cited above, you will see that the bin-functionannotates a list of objects ('annotate' here is used in the sense of -annotate). Or viewed other way you are slapping tags--as in Org tags or Twitter tags--to objects. So, an obect can have multiple tags.
The word tag (in the sense of org tag) also make sense because the original request was raised by the org-superagenda and org-ql author ... So, instead of -distribute or whatever other names have been proposed choose a name that reflects what the operation here is; and the operation is "Annotate and Group by Annotation" (if you squint a bit)
Proposal
-distribute
--- Distribute a set of objects among different bins; each bin is associated with a predicate function. In other words, an object belongs to a bin, if it satisfies the corresponding bin function.See also
The text was updated successfully, but these errors were encountered: