fidget::context::Context: add if_nonzero_else fuction#64
Merged
mkeeter merged 1 commit intomkeeter:mainfrom Apr 8, 2024
Merged
fidget::context::Context: add if_nonzero_else fuction#64mkeeter merged 1 commit intomkeeter:mainfrom
mkeeter merged 1 commit intomkeeter:mainfrom
Conversation
mkeeter
reviewed
Apr 8, 2024
fidget/src/core/context/mod.rs
Outdated
| let lhs = self.and(condition, a)?; | ||
| let n_condition = self.not(condition)?; | ||
| let rhs = self.and(n_condition, b)?; | ||
| self.add(lhs, rhs) |
Owner
There was a problem hiding this comment.
Suggested change
| self.add(lhs, rhs) | |
| self.or(lhs, rhs) |
(otherwise, it won't be fully simplified after tracing evaluation)
Contributor
Author
There was a problem hiding this comment.
Yes, you are correct - I was thinking about this backwards, as you can tell from my comment in #58. Honestly I keep getting confused by this construction, the "if zero then zero else" nature of it keeps tripping me up for some reason!
Merged
mkeeter
approved these changes
Apr 8, 2024
Merged
mkeeter
added a commit
that referenced
this pull request
Apr 8, 2024
This is a follow-up to #64, making a few tweaks: - Adds a test for conditional simplification - Adds a short description to the changelog - Removes the textual form, because I want that format to be 1:1 with opcodes - Removes the unit test, because it's identical to the doctest
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This implements an
if_nonzero_elsehelper function as implied in #58. Let me know if a Heaviside step function andif_nonnegative_elsewould be useful as well.