clara

http://www.clara-rules.org/
PB 2020-06-19T14:21:16.147Z

Hey all, is there a way to insert multiple records inside of a rule, one for each item in a list. Sorry, I think I'm not sure how to properly ask this but I think my example should describe this pretty well:

(defrule somerule
  [SomeRecord  (= ?list-of-ids list-of-ids)]
  =>
  (for [id ?list-of-ids]
    (insert! (->Addition id :some-key "icecream"))))

2020-06-19T14:24:07.148200Z

There is insert-all!that accepts a sequence of facts which may be useful to you https://cljdoc.org/d/com.cerner/clara-rules/0.20.0/api/clara.rules#insert-all!

PB 2020-06-19T14:24:54.149Z

@mbragg yes! but how do I generate that sequence of facts? It does not allow me to iterate over ?list-of-ids

PB 2020-06-19T14:29:52.149500Z

Oh, I was wrong, I was really tired last night. Thank you @mbragg