mschuene / stratege Goto Github PK
View Code? Open in Web Editor NEWclojure library for strategic term rewriting inspired by StrategoXT
License: Eclipse Public License 1.0
clojure library for strategic term rewriting inspired by StrategoXT
License: Eclipse Public License 1.0
Hi Maik,
Thank you for publishing this library. I'm trying to use it to create a generic dnf term rewriter. I'm not yet able to create recursive rules that match predicates of arbitrary lengths.
Simple predicates work:
[:not [:or a b]] ;=> [:and [:not a] [:not b]]
But how do I write rules that are recursive and will match predicates of arbitrary lengths, like:
[:not [:or a b c]] ;=> [:and [:not :a] [:not :b] [:not c]]
[:not [:or a b c d]] ;=> [:and [:not :a] [:not :b] [:not c] [:not d]]
[:not [:or a b c d e]] ;=> [:and [:not :a] [:not :b] [:not c] [:not d] [:not e]]
;; etc
Thanks,
Jeroen
Hi, some nice work here, potentially!
Excuse any ridiculously dumb questions, I'm new to this system.
However, this - following your example - does not give the right result. Any ideas?
(ns stratego.core)
(require '[stratege.core :as s :refer [defrule rules]])
;; Second examples from github/mschuene/stratege main page
(def propagate-constants-rules
(s/match-replace
[:and true x] x
[:and x true] x
[:and false x] false
[:and x false] false
[:or true x] true
[:or x true] true
[:or false x] x
[:or x false] x
[:not false] true
[:not true] false))
(def propagate-constants (s/downup propagate-constants-rules))
then
stratego.core=> (clojure.test/is (= true (propagate-constants [:and true [:or true false]])))
FAIL in () (form-init2163883587934145703.clj:1)
expected: (= true (propagate-constants [:and true [:or true false]]))
actual: (not (= true nil))
false
Why does propagate-constants return nil?
Surely it should propagate to true.
Once again, apologies if I'm missing something too obvious.
In stratege.core
you use the following function, which is only available since 1.7: http://clojuredocs.org/clojure.core/update
When I add the dependency [stratege "0.1.0"]
I also need to add the dependency to [criterium "0.4.3"]
, else I cannot require [stratege.core :as s :refer [rules]]
due to missing criterium.core
.
Maybe criterium could be a development-dependency, and not required at all in production code?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.