Maybe your objects could be defined by a map containing functions and objects.

So exampleAndList = {:fn and, :coll [a b c]}


And then eval goes through your objects recursively, using

(def eval [o]
(apply (:fn o) (map eval (:coll o)))) 

- with a special case that if o is not a map but say a Boolean you just return 
itself



> On 14 Aug 2020, at 02:24, Jack Park <jackp...@topicquests.org> wrote:
> 
> 
> The problem:
> 
> In Java, I have an interface IInferrable which is basically  boolean eval();
> 
> Any Java object which extends IInferrable, no matter what it is, will answer 
> to eval() and return a boolean.
> The idea lies at the heart of an inference engine.
> 
> But, I also define a class AndList which implements IInferrable and extends 
> java.util.ArrayList<Inferrable>
> 
> So, AndList, and its sibling OrList behave just like a List object, but also 
> will answer to eval() by running the collection and dealing with what each 
> element returns when it, too, is eval()'d.
> 
> I'd really love to discover how to pull that off in Clojure.
> 
> Many thanks in advance. -Jack
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/clojure/3e2ffc86-0e4f-4c0c-92c3-58e0848d5ba7o%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/4D1E5BB6-F34A-4379-A534-2B4F7B68CE18%40gmail.com.

Reply via email to