From 4d482c44df180625a64e34019abf7796399038b0 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Fri, 24 Feb 2023 16:52:27 +0100 Subject: Added more string/char functions --- std/String.bruijn | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'std/String.bruijn') diff --git a/std/String.bruijn b/std/String.bruijn index db526fe..9267f20 100644 --- a/std/String.bruijn +++ b/std/String.bruijn @@ -1,5 +1,7 @@ # MIT License, Copyright (c) 2022 Marvin Borner +:import std/Char C +:import std/Number . :import std/Number/Binary B :input std/List @@ -26,6 +28,11 @@ ni? \in? :test ("ab" ∋ 'b') (true) :test ("ab" ∋ 'c') (false) +# converts a string of digits into a number +number! from-digits ∘ (map C.number!) + +:test ((number! "123") =? (+123)) (true) + # splits string by newline character lines z [[rec]] rec ∅?(~broken) (^broken : empty) (^broken : (1 ~(~broken))) -- cgit v1.2.3