ref: 6ed494853cfc436672cc3d296f42034ea475dd40
parent: 4e8d03d374a17a3e0c691276a87022631c2c269a
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Jun 7 13:43:04 EDT 2016
Add 'chomp' function. Consumes a prefix from a string.
--- a/lib/std/bld.sub
+++ b/lib/std/bld.sub
@@ -8,6 +8,7 @@
bitset.myr
blat.myr
chartype.myr
+ chomp.myr
clear.myr
cmp.myr
consts.myr
--- /dev/null
+++ b/lib/std/chomp.myr
@@ -1,0 +1,13 @@
+use "hasprefix"
+
+pkg std =
+ const chomp : (str : byte[:], pfx : byte[:] -> byte[:])
+;;
+
+const chomp = {str, pfx
+ if std.hasprefix(str)
+ -> str[pfx.len:]
+ else
+ -> str
+ ;;
+}