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/String.bruijn | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'std/String.bruijn') diff --git a/std/String.bruijn b/std/String.bruijn index 4ee002b..567635b 100644 --- a/std/String.bruijn +++ b/std/String.bruijn @@ -3,6 +3,7 @@ :import std/Char C :import std/Math . :import std/Number/Binary B +:import std/Number/Conversion O :input std/List @@ -129,3 +130,9 @@ lines z [[rec]] ⧗ String → (List String) unlines concat-map (\(…;…) '\n') ⧗ (List String) → String :test (unlines ("ab" : {}"cd")) ("ab\ncd\n") + +# slightly stretched DJB2 +# WARNING: this may give weird results with/without padded zeros due to bad xor +hash O.²³‣ ∘ (foldl [[B.xor! (B.mul (+33b) 1) (B.mul 0 (+208121b))]] (+5381b)) ⧗ String → Number + +#‣ &hash -- cgit v1.2.3