Fork me on GitHub
#clara
<
2017-08-25
>
iku00088807:08:26

Not sure how I can express this, but is there a way to express a left-join type of a rule?

mikerod13:08:03

@iku000888 I’m thinking you’d probably write 2 rules in that case

mikerod13:08:16

or do some of the joining on the RHS - which I often hesitate to think is a good idea

mikerod13:08:20

(r/defrule joins
  [A (= ?id id)]
  [B (= ?id id)]
  =>
  (r/insert! (->C)))

(r/defrule nil-joins
  [A (= ?id id)]
  [:not [B (= ?id id)]]
  =>
  (r/insert! (->C)))

mikerod13:08:25

is that the “left join” sort of thing?

mikerod13:08:22

A always produce a C, just sometimes there is no B to go with an A

mikerod13:08:35

C can hold whatever info you wanted out of the join