-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add NAND and NOR number operations #3561
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
Open
Kryonn
wants to merge
12
commits into
josdejong:develop
Choose a base branch
from
Kryonn:code/nand-nor-op
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+875
−12
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5c0c824
code: add nand and nor number operations
Kryonn 4cfd5be
code: update nor
Kryonn 946c22b
code: final update nor
Kryonn 2db176a
code: nor update
Kryonn a123ac0
code: nor final update 2
Kryonn 1f28cbd
code: fix nor docs
Kryonn 4da755f
Merge branch 'develop' into code/nand-nor-op
Kryonn 843b371
code: fix NOR and implement NAND
Kryonn 11d48a3
Merge branch 'code/nand-nor-op' of https://github.com/Kryonn/mathjs i…
Kryonn 6430d61
code: Update index.d.ts
Kryonn f084bd8
code: finish tasks
Kryonn 4325643
code: fix test and functions
Kryonn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -278,6 +278,7 @@ kyle-compute <[email protected]> | |
| DongKwanKho <[email protected]> | ||
| Ikem Peter <[email protected]> | ||
| Josh Kelley <[email protected]> | ||
| Kryonn <[email protected]> | ||
| Richard Taylor <[email protected]> | ||
| NilsDietrich <[email protected]> | ||
|
|
||
|
|
||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| export const nandDocs = { | ||
| name: 'nand', | ||
| category: 'Logical', | ||
| syntax: [ | ||
| 'x nand y', | ||
| 'nand(x, y)' | ||
| ], | ||
| description: 'Logical nand. Test whether at least one of values is zero.', | ||
| examples: [ | ||
| 'nand(true, false)', | ||
| 'nand(true, true)', | ||
| 'nand(2, 4)' | ||
| ], | ||
| seealso: [ | ||
| 'not', 'or', 'xor' | ||
| ] | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| export const norDocs = { | ||
| name: 'nor', | ||
| category: 'Logical', | ||
| syntax: [ | ||
| 'x nor y', | ||
| 'nor(x, y)' | ||
| ], | ||
| description: 'Logical nor. Test if both values are zero', | ||
| examples: [ | ||
| 'nor(true, false)', | ||
| 'nor(false, false)', | ||
| 'nor(0, 4)' | ||
| ], | ||
| seealso: [ | ||
| 'not', 'or', 'xor' | ||
| ] | ||
| } |
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import { factory } from '../../utils/factory.js' | ||
| import { nandNumber } from '../../plain/number/logical.js' | ||
|
|
||
| const name = 'nand' | ||
| const dependencies = [ | ||
| 'typed', | ||
| 'and', | ||
| 'not' | ||
| ] | ||
|
|
||
| export const createNand = /* #__PURE__ */ factory(name, dependencies, ({ typed, and, not }) => { | ||
| /** | ||
| * Logical `nand`. Test if at least one of the inputs is zero. | ||
| * For matrices, the function is evaluated element wise. | ||
| * | ||
| * Syntax: | ||
| * | ||
| * math.nand(x, y) | ||
| * | ||
| * Examples: | ||
| * | ||
| * math.nand(2, 4) // returns false | ||
| * | ||
| * a = [2, 5, 0] | ||
| * b = [0, 22, 0] | ||
| * c = 0 | ||
| * | ||
| * math.nand(a, b) // returns [true, false, true] | ||
| * math.nand(b, c) // returns [true, true, true] | ||
| * | ||
| * See also: | ||
| * | ||
| * and, or, not, xor | ||
| * | ||
| * @param {number | BigNumber | bigint | Complex | Unit | Array | Matrix} x First value to check | ||
| * @param {number | BigNumber | bigint | Complex | Unit | Array | Matrix} y Second value to check | ||
| * @return {boolean | Array | Matrix} | ||
| * Returns true when at least one of the inputs is zero | ||
| */ | ||
| return typed( | ||
| name, | ||
| { | ||
| 'number, number': nandNumber, | ||
| 'bigint, bigint': nandNumber, | ||
|
|
||
| 'any, any': function (x, y) { | ||
| return not(and(x, y)) | ||
| } | ||
| } | ||
| ) | ||
| }) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import { factory } from '../../utils/factory.js' | ||
| import { norNumber } from '../../plain/number/logical.js' | ||
|
|
||
| const name = 'nor' | ||
| const dependencies = [ | ||
| 'typed', | ||
| 'or', | ||
| 'not' | ||
| ] | ||
|
|
||
| export const createNor = /* #__PURE__ */ factory(name, dependencies, ({ typed, or, not }) => { | ||
| /** | ||
| * Logical `nor`. Test if both of values are defined with zero. | ||
| * For matrices, the function is evaluated element wise. | ||
| * | ||
| * Syntax: | ||
| * | ||
| * math.nor(x, y) | ||
| * | ||
| * Examples: | ||
| * | ||
| * math.nor(2, 4) // returns false | ||
| * | ||
| * a = [2, 5, 0] | ||
| * b = [0, 22, 0] | ||
| * c = 0 | ||
| * | ||
| * math.nor(a, b) // returns [false, false, true] | ||
| * math.nor(b, c) // returns [true, false, true] | ||
| * | ||
| * See also: | ||
| * | ||
| * and, or, not, xor | ||
| * | ||
| * @param {number | BigNumber | bigint | Complex | Unit | Array | Matrix} x First value to check | ||
| * @param {number | BigNumber | bigint | Complex | Unit | Array | Matrix} y Second value to check | ||
| * @return {boolean | Array | Matrix} | ||
| * Returns true when both inputs are zero | ||
| */ | ||
| return typed( | ||
| name, | ||
| { | ||
| 'number, number': norNumber, | ||
| 'bigint, bigint': norNumber, | ||
|
|
||
| 'any, any': function (x, y) { | ||
| return not(or(x, y)) | ||
| } | ||
| } | ||
| ) | ||
| }) |
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
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
Oops, something went wrong.
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.
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.
As I mentioned in earlier review,
nandis actually a form ofor(sinceA nand B == (not A) or (not B)). Sonandshould go in the logical or precedence group (maybe rename it parseLogicalOrNand?? that's optional). And converselyA nor B == (not A) and (not B)is a form ofandso should go in this precedence group, which you could optionally renameparseLogicalAndNor. Thanks!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.
Solved. I reversed the group in which the NAND and NOR functions were inserted (NAND -> OR group, NOR -> AND group) and changed the names of the functions.