Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Tim McNamara
notebook
Commits
37e95b0a
Commit
37e95b0a
authored
Jun 14, 2019
by
Tim McNamara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add multi-valued-logic.md
parent
2942d3eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
rust/multi-valued-logic.md
rust/multi-valued-logic.md
+17
-0
No files found.
rust/multi-valued-logic.md
0 → 100644
View file @
37e95b0a
In Rust, it's pretty easy to create a logical type that can encode "unknown" or
"indeterminate" system.
```
type TernaryLogic = Option(bool);
```
This approach is also available in Go and other languages with pointers:
```
*bool
```
When de-referencing the pointer,
`nil`
equals unknown and
`true`
/
`false`
are represented.
I'm not actually sure how the compiler can distinguish between a null pointer
and false. Something more to learn, I guess.
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment