From 703661dcfcf96e23acedf7c2a6d36cda3fb68bc6 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Tue, 26 Jan 2010 14:59:19 -0500 Subject: Handling errors during commit --- lib/ur/string.ur | 11 +++++++++++ lib/ur/string.urs | 1 + 2 files changed, 12 insertions(+) (limited to 'lib/ur') diff --git a/lib/ur/string.ur b/lib/ur/string.ur index 4025cf68..07d7e6b8 100644 --- a/lib/ur/string.ur +++ b/lib/ur/string.ur @@ -38,6 +38,17 @@ fun all f s = al 0 end +fun mp f s = + let + fun mp' i acc = + if i < 0 then + acc + else + mp' (i - 1) (str (f (sub s i)) ^ acc) + in + mp' (length s - 1) "" + end + fun newlines [ctx] [[Body] ~ ctx] s : xml ([Body] ++ ctx) [] [] = case split s #"\n" of None => cdata s diff --git a/lib/ur/string.urs b/lib/ur/string.urs index 5590b50c..557e73c0 100644 --- a/lib/ur/string.urs +++ b/lib/ur/string.urs @@ -20,5 +20,6 @@ val split : t -> char -> option (string * string) val msplit : {Haystack : t, Needle : t} -> option (string * char * string) val all : (char -> bool) -> string -> bool +val mp : (char -> char) -> string -> string val newlines : ctx ::: {Unit} -> [[Body] ~ ctx] => string -> xml ([Body] ++ ctx) [] [] -- cgit v1.2.3