This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns clara.examples.dup-nodes | |
(:refer-clojure :exclude [==]) | |
(:require [clara.rules.accumulators :as acc] | |
[clara.rules :refer :all] | |
[potemkin :as p])) | |
(p/defrecord+ BindingFact []) | |
(p/defrecord+ InsertionFact[b]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0 getstatic #10 <unmap_test/core__init.const__0> | |
3 invokevirtual #16 <clojure/lang/Var.getRawRoot> | |
6 checkcast #18 <clojure/lang/IFn> | |
9 getstatic #22 <unmap_test/core__init.const__1> | |
12 invokeinterface #26 <clojure/lang/IFn.invoke> count 2 | |
17 new #28 <unmap_test/core$loading__5340__auto____965> | |
20 dup | |
21 invokespecial #31 <unmap_test/core$loading__5340__auto____965.<init>> | |
24 checkcast #18 <clojure/lang/IFn> | |
27 invokeinterface #33 <clojure/lang/IFn.invoke> count 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0 ldc #104 <clojure.core> | |
2 ldc #106 <in-ns> | |
4 invokestatic #112 <clojure/lang/RT.var> | |
7 checkcast #12 <clojure/lang/Var> | |
10 putstatic #10 <unmap_test/core__init.const__0> | |
13 aconst_null | |
14 ldc #114 <unmap-test.core> | |
16 invokestatic #118 <clojure/lang/Symbol.intern> | |
19 checkcast #120 <clojure/lang/AFn> | |
22 putstatic #22 <unmap_test/core__init.const__1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package unmap_test; | |
import clojure.lang.AFn; | |
import clojure.lang.Compiler; | |
import clojure.lang.IFn; | |
import clojure.lang.IPersistentMap; | |
import clojure.lang.Keyword; | |
import clojure.lang.LockingTransaction; | |
import clojure.lang.RT; | |
import clojure.lang.Symbol; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns clara.examples.duplicates | |
(:require [clara.rules.accumulators :as acc] | |
[clara.rules :refer :all] | |
[clara.rules.compiler :as c])) | |
(defrecord Temperature [t]) | |
(defrecord Cold [t]) | |
(defrule is-cold? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Determine the relative performance of turning a vector into a list | |
;; and popping items off the list versus just using the vector. | |
;; The list approach is asymptotically faster, but the idea is to determine | |
;; at what point the overhead of creating a new list is worth it. | |
(defn time-list [n] | |
(let [init-vec (mapv (constantly 1) | |
(range n))] | |
(time (loop [l (into () init-vec)] | |
(let [r (rest l) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clara.test-rules> (defrule arule [clojure.lang.Keyword (= :a)] => (println "I fired")) | |
#'clara.test-rules/arule | |
clara.test-rules> (-> (mk-session [arule]) (insert :a) (fire-rules)) | |
I fired | |
#object[clara.rules.engine.LocalSession 0x2c848a4e "clara.rules.engine.LocalSession@2c848a4e"] | |
clara.test-rules> (-> (mk-session [arule]) (insert :b) (fire-rules)) | |
I fired | |
#object[clara.rules.engine.LocalSession 0x107e6fae "clara.rules.engine.LocalSession@107e6fae"] | |
clara.test-rules> (defrule arule2 [clojure.lang.Keyword (= this :a)] => (println "I fired")) | |
#'clara.test-rules/arule2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package clara.benchmark; | |
import java.util.Iterator; | |
/** | |
* Benchmark interface. | |
*/ | |
public interface IBenchmark<T, E> { | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn constant-accum [v] | |
(accumulate | |
:initial-value v | |
:reduce-fn (constantly v) | |
:combine-fn (constantly v) | |
:retract-fn (constantly v) | |
:convert-return-fn identity)) | |
(deftest nil-accumulate-node-test | |
(let [r1 (dsl/parse-rule [[?r <- (constant-accum nil) :from [Cold]]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clara.test-rules> (com/clear-session-cache!) | |
{} | |
clara.test-rules> (defrule first->second-rule | |
[First] | |
=> | |
(insert! (->Second))) | |
#'clara.test-rules/first->second-rule | |
clara.test-rules> (defquery second-query | |
[] | |
[Second]) |
OlderNewer