-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
46cc8f5
commit ca39074
Showing
10 changed files
with
135 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
|
@@ -188,7 +188,7 @@ a { | |
color: #b1ee13; | ||
} | ||
|
||
.code .mixfix { | ||
.code .mixfix, .code .prefix { | ||
color: #eee513; | ||
} | ||
|
||
|
This file contains 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 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,21 @@ | ||
:import std/Number . | ||
|
||
# composition, bluebird combinator | ||
…∘… [[[2 (1 0)]]] | ||
|
||
:test (((inc ∘ (mul (+2))) (+3)) =? (+7)) ([[1]]) | ||
|
||
# 2x composition, blackbird combinator | ||
…∘∘… [[[[3 (2 1 0)]]]] | ||
|
||
:test (((inc ∘∘ mul) (+2) (+3)) =? (+7)) ([[1]]) | ||
|
||
# 3x composition, bunting combinator | ||
…∘∘∘… [[[[[4 (3 2 1 0)]]]]] | ||
|
||
:test (((inc ∘∘∘ (add ∘∘ mul)) (+1) (+2) (+4)) =? (+7)) ([[1]]) | ||
|
||
# reverse composition, queer bird combinator | ||
…→… [[[1 (2 0)]]] | ||
|
||
:test ((((mul (+2)) → inc) (+3)) =? (+7)) ([[1]]) |
This file contains 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,21 @@ | ||
:import std/Combinator . | ||
:import std/List . | ||
:import std/Math M | ||
:import std/Number/Binary . | ||
|
||
# hailstone sequence using binary shifts | ||
hailstone y [[(0 =? (+1b)) {}0 go]] | ||
go 0 : (=²?0 (1 /²0) (1 (↑¹0 + 0))) | ||
|
||
# --- tests --- | ||
|
||
seq-27 hailstone (+27b) | ||
|
||
:test (∀seq-27) ((+112)) | ||
:test (take (+4) seq-27) ((+27b) : ((+82b) : ((+41b) : {}(+124b)))) | ||
:test (take (+4) <~>seq-27) ((+1b) : ((+2b) : ((+4b) : {}(+8b)))) | ||
|
||
all-below-100000 [0 : ∀(hailstone 0)] <$> seq | ||
seq take (+1000) (iterate ++‣ (+1b)) | ||
|
||
main [head (max-by (M.compare ⋔ tail) all-below-100000)] |
This file contains 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,10 @@ | ||
:import std/Combinator . | ||
:import std/Char C | ||
:import std/List . | ||
:import std/Math . | ||
|
||
levenshtein y [[[∅?1 ∀0 (∅?0 ∀1 (0 (1 [[[[go]]]])))]]] | ||
go (C.eq? 3 1) (6 2 0) ++(lmin ((6 2 0) : ((6 5 0) : {}(6 2 4)))) | ||
|
||
:test ((levenshtein "rosettacode" "raisethysword") =? (+8)) ([[1]]) | ||
:test ((levenshtein "kitten" "sitting") =? (+3)) ([[1]]) |
This file contains 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,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) |
This file contains 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 was deleted.
Oops, something went wrong.