stdlib: Add wrap function.
authorRichard W.M. Jones <rjones@redhat.com>
Fri, 10 Jan 2020 12:15:41 +0000 (12:15 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Fri, 10 Jan 2020 12:16:07 +0000 (12:16 +0000)
stdlib/prelude.gl

index f4ab20e..a73ef1a 100644 (file)
@@ -38,6 +38,20 @@ tactic *exists (filename) = @{
 }
 
 #----------------------------------------------------------------------
+# Basic functions.
+
+# Wrap list of strings in a call or tactic.
+pure function wrap (wrapper, xs) = @{
+    echo '['
+    for x in %xs; do
+        echo %wrapper "( "
+        quoted_string "$x"
+        echo " ),"
+    done
+    echo ']'
+}
+
+#----------------------------------------------------------------------
 # Text functions.
 
 # Sort + uniq a list.