-
-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace numsymb with pattern matching versions [in progress] #391
base: main
Are you sure you want to change the base?
Replace numsymb with pattern matching versions [in progress] #391
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice start!
src/sicmutils/numsymb-rules
Outdated
negation of `x`. For boolean `x`, returns the negation of `x`." | ||
[x] | ||
(let [RS (r/ruleset | ||
(? ?x true?) r/=> false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would import =>
directly so you don't need the slash. If you are matching a literal you can do true => false
, or you can write (? ?x boolean?) => (: #(not (% '?x)))
, I believe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you mean (? #(not (% '?x)))
(? instead of :) ?
src/sicmutils/numsymb-rules
Outdated
?x r/=> (not ?x))] | ||
(RS x))) | ||
|
||
;; basic tests - these should probavbly live elsewhere? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see the convention for other namespaces. Put these in tests
, same namespace with -test
appended.
src/sicmutils/numsymb-rules
Outdated
(RS x))) | ||
|
||
;; basic tests - these should probavbly live elsewhere? | ||
(let [v [true false 1 0 'a '() ()]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(doseq [v ...]
(is (= (sym:not v) ((sym/symbolic-operator 'not) v))))
src/sicmutils/numsymb-rules
Outdated
(? ?x n:pi-over-4-mod-pi?) r/=> 1 | ||
(? ?x n:-pi-over-4-mod-pi?) r/=> -1 | ||
(? ?x n:pi-over-2-mod-pi?) r/=> (u/illegal "Undefined: tan") | ||
(? ?x v/number?) r/=> (?? #(Math/tan (% '?x))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
single ?
, not ??
, since you are not splicing in a result
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused by the difference; is ?? used for binding collections, whereas ? is for binding "single" variables?
afa6dd7
to
c33ef42
Compare
Addresses sicmutils/placeholder#70 . Currently, the pattern-matching versions of
numsymb
live in a different namespacenumsymb-rules
. Onlytan
,atan
,gcd
andnot
are currently implemented - thought it would be good to ask for feedback in an initial stage to make sure I'm doing this right.Very basic testing throughout the code, presumably these should go somewhere in the
/test/sicmutils
folder?