stdlib: Implement sort function.
authorRichard W.M. Jones <rjones@redhat.com>
Sat, 4 Jan 2020 11:56:00 +0000 (11:56 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Sat, 4 Jan 2020 11:56:00 +0000 (11:56 +0000)
stdlib/prelude.gl

index 15b1c0b..7e6cbd5 100644 (file)
@@ -37,6 +37,17 @@ tactic *exists (filename) = {
     test -f %filename || exit 99
 }
 
+#----------------------------------------------------------------------
+# Text functions.
+
+# Sort + uniq a list.
+function sort (xs) = {
+    for f in %xs; do echo "$f"; done | sort -u
+}
+
+#----------------------------------------------------------------------
+# File functions.
+
 # Expand a wildcard into a list of filenames.
 function wildcard (wc) = {
     shopt -s nullglob