diff options
author | Marvin Borner | 2024-03-02 16:16:51 +0100 |
---|---|---|
committer | Marvin Borner | 2024-03-02 19:30:59 +0100 |
commit | ca3907431bfde5aa0715945222ce777d72e6b411 (patch) | |
tree | 5399b72899c5d66f94782892ba9dbf29839aca22 /samples/rosetta/ternary_logic.bruijn | |
parent | 46cc8f5b0da07d8c7cb354c7b7a281b8d0f3d7bf (diff) |
Docs & samples
Diffstat (limited to 'samples/rosetta/ternary_logic.bruijn')
-rw-r--r-- | samples/rosetta/ternary_logic.bruijn | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/samples/rosetta/ternary_logic.bruijn b/samples/rosetta/ternary_logic.bruijn new file mode 100644 index 0000000..037ac41 --- /dev/null +++ b/samples/rosetta/ternary_logic.bruijn @@ -0,0 +1,71 @@ +true [[[0]]] + +maybe [[[1]]] + +false [[[2]]] + +¬‣ [0 true maybe false] + +:test (¬true) (false) +:test (¬maybe) (maybe) +:test (¬false) (true) + +…⋀… [[1 (0 1 1 1) (0 0 0 1) (0 0 0 0)]] + +:test (true ⋀ true) (true) +:test (true ⋀ maybe) (maybe) +:test (true ⋀ false) (false) +:test (maybe ⋀ true) (maybe) +:test (maybe ⋀ maybe) (maybe) +:test (maybe ⋀ false) (false) +:test (false ⋀ true) (false) +:test (false ⋀ maybe) (false) +:test (false ⋀ false) (false) + +…⋁… [[1 (0 0 0 0) (0 1 0 0) (0 1 1 1)]] + +:test (true ⋁ true) (true) +:test (true ⋁ maybe) (true) +:test (true ⋁ false) (true) +:test (maybe ⋁ true) (true) +:test (maybe ⋁ maybe) (maybe) +:test (maybe ⋁ false) (maybe) +:test (false ⋁ true) (true) +:test (false ⋁ maybe) (maybe) +:test (false ⋁ false) (false) + +…⊃… [[1 (0 true 0 1) (0 true 1 1) (0 1 1 1)]] + +:test (true ⊃ true) (true) +:test (true ⊃ maybe) (true) +:test (true ⊃ false) (true) +:test (maybe ⊃ true) (maybe) +:test (maybe ⊃ maybe) (maybe) +:test (maybe ⊃ false) (true) +:test (false ⊃ true) (false) +:test (false ⊃ maybe) (maybe) +:test (false ⊃ false) (true) + +…≡… [[1 (0 true 0 1) (0 1 1 1) (0 0 0 0)]] + +:test (true ≡ true) (true) +:test (true ≡ maybe) (maybe) +:test (true ≡ false) (false) +:test (maybe ≡ true) (maybe) +:test (maybe ≡ maybe) (maybe) +:test (maybe ≡ false) (maybe) +:test (false ≡ true) (false) +:test (false ≡ maybe) (maybe) +:test (false ≡ false) (true) + +# --- result samples --- + +:import std/List . + +main [[inp <> "=" <> !res ++ "\n"] <++> (cross3 ops trits trits)] + !‣ [0 "false" "maybe" "true"] + …<>… [[1 ++ " " ++ 0]] + inp 0 [[~1 <> (0 [[!1 <> (0 [[!1]])]])]] + res ^(^0) ^(~0) ^(~(~0)) + ops (…⋀… : "and") : ((…⋁… : "or") : ((…⊃… : "if") : {}(…≡… : "equiv"))) + trits true : (maybe : {}false) |