Skip to content

Commit

Permalink
Merge pull request #5 from haakonsmith/fixing-multiple-complex-operat…
Browse files Browse the repository at this point in the history
…or-evaluation

Add count limit to evaluation, fixes #4
  • Loading branch information
Thumuss authored Aug 23, 2024
2 parents 8440023 + 1b1bc39 commit b2ddafa
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions main.typ
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
regex("([(]+.*[)]|[a-zA-Z](_\d+)?)+[ ]*⇒[ ]*([(]+.*[)]|[a-zA-Z](_\d+)?)+"),
) // regex hell
if (pos != none) {
text = text.replace(pos.text, "not " + pos.text.replace("", "or"))
text = text.replace(pos.text, "not " + pos.text.replace("", "or", count: 1))
} else { break }
}

Expand All @@ -70,7 +70,7 @@
regex("([(]+.*[)]|[a-zA-Z](_\d+)?)+[ ]*↑[ ]*([(]+.*[)]|[a-zA-Z](_\d+)?)+"),
)
if (pos != none) {
text = text.replace(pos.text, "not(" + pos.text.replace("", "and") + ")")
text = text.replace(pos.text, "not(" + pos.text.replace("", "and", count: 1) + ")")
} else { break }
}

Expand All @@ -80,7 +80,7 @@
regex("([(]+.*[)]|[a-zA-Z](_\d+)?)+[ ]*↓[ ]*([(]+.*[)]|[a-zA-Z](_\d+)?)+"),
)
if (pos != none) {
text = text.replace(pos.text, "not(" + pos.text.replace("", "or") + ")")
text = text.replace(pos.text, "not(" + pos.text.replace("", "or", count: 1) + ")")
} else { break }
}

Expand All @@ -90,7 +90,7 @@
regex("([(]+.*[)]|[a-zA-Z](_\d+)?)+[ ]*⇔[ ]*([(]+.*[)]|[a-zA-Z](_\d+)?)+"),
)
if (pos != none) {
text = text.replace(pos.text, "(" + pos.text.replace("", "==") + ")")
text = text.replace(pos.text, "(" + pos.text.replace("", "==", count: 1) + ")")
} else { break }
}

Expand All @@ -115,7 +115,7 @@
regex("([(]+.*[)]|[a-zA-Z](_\d+)?)+[ ]*⊕[ ]*([(]+.*[)]|[a-zA-Z](_\d+)?)+"),
)
if (pos != none) {
text = text.replace(pos.text, "not (" + pos.text.replace("", "==") + ")")
text = text.replace(pos.text, "not (" + pos.text.replace("", "==", count: 1) + ")")
} else { break }
}

Expand Down Expand Up @@ -343,4 +343,4 @@
#truth-table($A and B$, reverse: true)
//#karnaugh($A and B and C$)
//#karnaugh($A and B and C$)
//#karnaugh($A and B and C and D$)*/
//#karnaugh($A and B and C and D$)*/

0 comments on commit b2ddafa

Please sign in to comment.