diff options
author | Marvin Borner | 2023-02-24 15:36:59 +0100 |
---|---|---|
committer | Marvin Borner | 2023-02-24 15:39:24 +0100 |
commit | 1fcb81203e886b6b1e851a94c5fb301c9d33ec89 (patch) | |
tree | 492158ebbabf6fda933a969373fdf5b5d55a92ed /std/Unary.bruijn | |
parent | c371838c15ab245bd9b1db3947747c431a95040e (diff) |
Moved number implementations
Diffstat (limited to 'std/Unary.bruijn')
-rw-r--r-- | std/Unary.bruijn | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/std/Unary.bruijn b/std/Unary.bruijn deleted file mode 100644 index cf72e3b..0000000 --- a/std/Unary.bruijn +++ /dev/null @@ -1,57 +0,0 @@ -# MIT License, Copyright (c) 2022 Marvin Borner -# classic Church style numerals - -:import std/Logic . - -zero [[0]] - -# returns true if a unary number is zero -zero? [0 [[[0]]] [[1]]] ⧗ Unary → Boolean - -=?‣ zero? - -:test (=?(+0u)) (true) -:test (=?(+42u)) (false) - -# adds 1 to a unary number -inc [[[1 (2 1 0)]]] ⧗ Unary → Unary - -++‣ inc - -:test (++(+0u)) ((+1u)) -:test (++(+1u)) ((+2u)) -:test (++(+42u)) ((+43u)) - -# subs 1 from a unary number -dec [[[2 [[0 (1 3)]] [1] [0]]]] ⧗ Unary → Unary - ---‣ dec - -:test (--(+0u)) ((+0u)) -:test (--(+1u)) ((+0u)) -:test (--(+42u)) ((+41u)) - -# adds two unary numbers -add [[[[3 1 (2 1 0)]]]] ⧗ Unary → Unary → Unary - -…+… add - -:test ((+0u) + (+2u)) ((+2u)) -:test ((+5u) + (+3u)) ((+8u)) - -# muls two unary numbers -mul [[[2 (1 0)]]] ⧗ Unary → Unary → Unary - -…⋅… mul - -:test ((+0u) ⋅ (+2u)) ((+0u)) -:test ((+2u) ⋅ (+3u)) ((+6u)) - -# exponentiates two unary numbers -# gives 1 if exponent is 0 -exp [[0 1]] ⧗ Unary → Unary → Unary - -…^… exp - -:test ((+1u) ^ (+0u)) ((+1u)) -:test ((+2u) ^ (+3u)) ((+8u)) |