diff options
author | Marvin Borner | 2024-03-03 15:03:41 +0100 |
---|---|---|
committer | Marvin Borner | 2024-03-03 22:29:24 +0100 |
commit | 6ae44d09faa0ae353c0818705503cad42127d102 (patch) | |
tree | a923d00d520f85a608f51416184e5b3b6f178549 /std/String.bruijn | |
parent | 03155d6e515c76d5ab59f814592484c849313130 (diff) |
Even more samples
wtf
Diffstat (limited to 'std/String.bruijn')
-rw-r--r-- | std/String.bruijn | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/std/String.bruijn b/std/String.bruijn index 76121ee..5af9574 100644 --- a/std/String.bruijn +++ b/std/String.bruijn @@ -29,17 +29,26 @@ ni? \in? ⧗ String → Char → Boolean :test ("ab" ∋ 'c') (false) # converts a string of digits into a number -string→number from-digits ∘ (map C.char→number) ⧗ String → Number +string→unsigned-number from-digits ∘ (map C.char→number) ⧗ String → Number -:test (%(string→number "123")) ((+123)) +:test (%(string→unsigned-number "123")) ((+123)) # converts a signed string of digits into a number -string→signed-number [(sign ^0) (string→number ~0)] ⧗ String → Number +string→signed-number [(sign ^0) (string→unsigned-number ~0)] ⧗ String → Number sign [(B.eq? 0 '-') -‣ i] :test (%(string→signed-number "+123")) ((+123)) :test (%(string→signed-number "-123")) ((-123)) +# converts signed/unsigned number strings to a number +string→number [C.les? ^0 '0' signed unsigned] ⧗ String → Number + signed string→signed-number 0 + unsigned string→unsigned-number 0 + +:test (%(string→number "123")) ((+123)) +:test (%(string→number "+123")) ((+123)) +:test (%(string→number "-123")) ((-123)) + # converts a number to a string number→string (map C.number→char) ∘ digits ⧗ Number → String |