From fe1fe57f358472561041cde12a48d28b8bd247a9 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sun, 27 Oct 2024 18:45:21 +0100 Subject: Improvements in maps, sets, and parsing --- std/Number/Binary.bruijn | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'std/Number/Binary.bruijn') diff --git a/std/Number/Binary.bruijn b/std/Number/Binary.bruijn index c778890..3dc6b18 100644 --- a/std/Number/Binary.bruijn +++ b/std/Number/Binary.bruijn @@ -200,9 +200,9 @@ and! binary! ∘∘ (ψ* zip-with …⋀?… list!) ⧗ Binary → Binary → Bi …⋀!… and! -:test (and! (+1b) (+0b)) ((+0b)) -:test (and! (+5b) (+4b)) ((+4b)) -:test (and! (+10b) (+12b)) ((+8b)) +:test ((+1b) ⋀! (+0b)) ((+0b)) +:test ((+5b) ⋀! (+4b)) ((+4b)) +:test ((+10b) ⋀! (+12b)) ((+8b)) # logical or on two binary numbers # TODO: Fix for numbers with different length (→ zero padding?) @@ -210,11 +210,19 @@ or! binary! ∘∘ (ψ* zip-with …⋁?… list!) ⧗ Binary → Binary → Bin …⋁!… or! -:test (or! (+10b) (+12b)) ((+14b)) +:test ((+10b) ⋁! (+12b)) ((+14b)) # :test (or! (+1b) (+0b)) ((+1b)) # :test (or! (+5b) (+3b)) ((+7b)) +# logical or on two binary numbers +# TODO: Fix for numbers with different length (→ zero padding?) +xor! binary! ∘∘ (ψ* zip-with …^?… list!) ⧗ Binary → Binary → Binary + +…^!… xor! + +:test (((+10b) ^! (+12b)) =? (+6b)) (true) + # adds 1 to a binary number (can introduce leading 0s) inc [~(0 z a¹ a⁰)] ⧗ Binary → Binary z (+0b) : (+1b) -- cgit v1.2.3