From 6ae44d09faa0ae353c0818705503cad42127d102 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sun, 3 Mar 2024 15:03:41 +0100 Subject: Even more samples wtf --- std/String.bruijn | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'std/String.bruijn') 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 -- cgit v1.2.3