summaryrefslogtreecommitdiff
path: root/common.sml
diff options
context:
space:
mode:
authorVladimir Azarov <avm@intermediate-node.net>2025-05-25 23:46:06 +0200
committerVladimir Azarov <avm@intermediate-node.net>2025-05-25 23:46:06 +0200
commita952ae451cc27d5de3877bb522db6c050532ea2a (patch)
treebb65fb619721729dbfeddc4671f0e04b08c989ab /common.sml
parentd9c809a5550b2fe23b2fd1e66672b503730d55f1 (diff)
Nested expressions
Diffstat (limited to 'common.sml')
-rw-r--r--common.sml9
1 files changed, 9 insertions, 0 deletions
diff --git a/common.sml b/common.sml
index 02c3724..e947e0f 100644
--- a/common.sml
+++ b/common.sml
@@ -134,6 +134,15 @@ in
fun printf g = Fold.fold ctx g
end
+fun sprintf g =
+let
+ val buf = ref []
+ fun output s = buf := s :: !buf
+ fun finish _ = String.concat $ rev $ !buf
+in
+ Fold.fold ((false, makePrintfBase output), finish)
+end g
+
fun Printf out g = Fold.fold ((false, out), fn _ => ()) g
local