aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--samples/fun/interpreter.bruijn5
-rw-r--r--std/Number/Binary.bruijn20
2 files changed, 12 insertions, 13 deletions
diff --git a/samples/fun/interpreter.bruijn b/samples/fun/interpreter.bruijn
index c2b8020..2e0673a 100644
--- a/samples/fun/interpreter.bruijn
+++ b/samples/fun/interpreter.bruijn
@@ -3,9 +3,8 @@
# note that Tromp's IO uses an additional abstraction at the beginning ("00" ++ ...)
:import std/Combinator .
-:import std/Number .
+:import std/Number/Binary .
:import std/List .
-:import std/Char C
uni [0 0] int [0 Ω] ⧗ (List Bit) → Term
int [[[0 go (2 2) 1]]]
@@ -23,7 +22,7 @@ uni [0 0] int [0 Ω] ⧗ (List Bit) → Term
case-11 [3 [3 var] 4]
var [1 (0 3)]
-str→blc map (=?‣ ∘ C.number!)
+str→blc map (c ∘ lsb)
:test (str→blc "0010") ([[1]] : ([[1]] : ([[0]] : {}[[1]])))
diff --git a/std/Number/Binary.bruijn b/std/Number/Binary.bruijn
index 28a3f7f..6445d9f 100644
--- a/std/Number/Binary.bruijn
+++ b/std/Number/Binary.bruijn
@@ -78,19 +78,19 @@ zero? [0 true [false] i] ⧗ Binary → Boolean
:test (=?(+1b)) (false)
# extracts least significant bit from a binary number
-lst [0 b⁰ [b¹] [b⁰]] ⧗ Binary → Bit
+lsb [0 b⁰ [b¹] [b⁰]] ⧗ Binary → Bit
-:test (lst (+0b)) (b⁰)
-:test (lst (+1b)) (b¹)
-:test (lst (+42b)) (b⁰)
+:test (lsb (+0b)) (b⁰)
+:test (lsb (+1b)) (b¹)
+:test (lsb (+42b)) (b⁰)
# extracts most significant bit from a binary number
# not really useful for binary numbers, but part of interface
-mst [=?0 b⁰ b¹] ⧗ Binary → Bit
+msb [=?0 b⁰ b¹] ⧗ Binary → Bit
-:test (mst (+0b)) (b⁰)
-:test (mst (+1b)) (b¹)
-:test (mst (+42b)) (b¹)
+:test (msb (+0b)) (b⁰)
+:test (msb (+1b)) (b¹)
+:test (msb (+42b)) (b¹)
# extracts nth bit from a binary number
nth …!!… ∘ list! ⧗ Binary → Number → Bit
@@ -277,7 +277,7 @@ div² [~(0 z a¹ a⁰)] ⧗ Binary → Binary
:test (/²(+5b) =? (+2b)) (true)
# returns true if the number is even (remainder mod 2 == 0)
-even? ¬‣ ∘ lst ⧗ Binary → Boolean
+even? ¬‣ ∘ lsb ⧗ Binary → Boolean
=²?‣ even?
@@ -287,7 +287,7 @@ even? ¬‣ ∘ lst ⧗ Binary → Boolean
:test (even? (+42b)) (true)
# returns true if the number is odd (remainder mod 2 == 1)
-odd? lst ⧗ Binary → Boolean
+odd? lsb ⧗ Binary → Boolean
≠²?‣ odd?