shithub: mc

Download patch

ref: 69c70ba14ea083bf65395ee45f3aff5956e77d83
parent: bc046635d6368a7e81bcc172efb121d54b05ebcd
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Jun 9 10:54:55 EDT 2016

Return true/false from chomp.

--- a/lib/std/chomp.myr
+++ b/lib/std/chomp.myr
@@ -1,13 +1,14 @@
 use "hasprefix"
 
 pkg std =
-	const chomp	: (str : byte[:], pfx : byte[:] -> byte[:])
+	const chomp	: (str : byte[:]#, pfx : byte[:] -> bool)
 ;;
 
 const chomp = {str, pfx
-	if std.hasprefix(str, pfx)
-		-> str[pfx.len:]
+	if std.hasprefix(str#, pfx)
+		str# = str#[pfx.len:]
+		-> true
 	else
-		-> str
+		-> false
 	;;
 }