Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Proof Assistant with Solver
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Zhang, Jenny
Proof Assistant with Solver
Commits
4964626c
Commit
4964626c
authored
9 months ago
by
Jenny Zhang
Browse files
Options
Downloads
Patches
Plain Diff
Define linkSequentNode function to link a new node to an existing node, prioritizing the left side
parent
81aed659
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/utils/sequentAst.js
+32
-4
32 additions, 4 deletions
src/utils/sequentAst.js
with
32 additions
and
4 deletions
src/utils/sequentAst.js
+
32
−
4
View file @
4964626c
function
sequentAst
(
value
,
left
,
right
)
{
// Define sequentNode constructor function
function
sequentNode
(
value
,
left
,
right
)
{
this
.
value
=
value
;
this
.
value
=
value
;
this
.
left
=
left
;
this
.
left
=
left
;
this
.
right
=
right
;
this
.
right
=
right
;
}
}
function
isSequentAst
(
obj
)
{
// Define isSequentNode function to check if an object is an instance of sequentNode
return
obj
instanceof
sequentAst
&&
function
isSequentNode
(
obj
)
{
return
obj
instanceof
sequentNode
&&
'
value
'
in
obj
&&
'
value
'
in
obj
&&
'
left
'
in
obj
&&
'
left
'
in
obj
&&
'
right
'
in
obj
;
'
right
'
in
obj
;
}
}
\ No newline at end of file
// Define linkSequentNode function to link a new node to an existing node, prioritizing the left side
function
linkSequentNode
(
existingNode
,
newNode
)
{
if
(
!
isSequentNode
(
existingNode
))
{
throw
new
Error
(
'
Existing node must be a sequentNode
'
);
}
if
(
!
isSequentNode
(
newNode
))
{
throw
new
Error
(
'
New node must be a sequentNode
'
);
}
// Prioritize linking to the left
if
(
!
existingNode
.
left
)
{
existingNode
.
left
=
newNode
;
}
else
if
(
!
existingNode
.
right
)
{
existingNode
.
right
=
newNode
;
}
else
{
// If both left and right nodes are occupied, recursively try to link to the left child node
linkNode
(
existingNode
.
left
,
newNode
);
}
}
module
.
exports
=
{
sequentNode
,
isSequentNode
,
linkSequentNode
};
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment