<html dir="ltr"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body class="" style="text-align:left; direction:ltr;"><div>Am Dienstag, dem 21.12.2021 um 16:28 +0000 schrieb Sean Charles (emacstheviking):</div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex">Hi Volker, I use code like this all the time for !IO and folding,<div class=""><br class=""></div><div class=""><div class=""><font face="Courier New" style="font-size: 14px;" class="">run_info(Options, !IO) :-</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class=""> aio.format("@cy:Environment variables:@-\n", [], !IO),</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class=""><br class=""></font></div><div class=""><font face="Courier New" style="font-size: 14px;" class=""> list.foldl(</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class=""> (pred(S::in, !.IO::di, !:IO::uo) is det :-</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class=""> get_env_str(S, "", ENV, !IO),</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class=""> aio.format("@yl:%15s:@- %s\n",</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class=""> [s(S), s(ENV)],</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class=""> !IO)</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class=""> ), ["FELT_INST", "FELT_DOCS", "FELT_PAGER", "FELT_EDITOR",</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class=""> "FELT_LEX", "FELT_AST", "FELT_TRN"],</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class=""> !IO),</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class=""><br class=""></font></div><div class=""><font face="Courier New" style="font-size: 14px;" class=""> aio.format("@cy:Command line options:@-\n", [], !IO),</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class=""><br class=""></font></div><div class=""><font face="Courier New" style="font-size: 14px;" class=""> list.foldl(</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class=""> (pred(K::in, !.IO::di, !:IO::uo) is det :-</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class=""> map.lookup(Options, K, V),</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class=""> aio.format("@yl:%15s:@- %s\n",</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class=""> [s(string(K)), s(string(V))],</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class=""> !IO)</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class=""> ),</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class=""> map.sorted_keys(Options),</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class=""> !IO).</font></div></div><div class=""><br class=""></div><div class="">Like Zoltan says, the code practically writes itself, I’ve not found the need to for threading !IO through anything to be honest!</div></blockquote><div><br></div><div>But that's exactly what you're doing in the example above, by using foldl.</div><div><br></div><div>Cheers, Volker</div></body></html>