stdlib: Implement join() function.
[goals.git] / stdlib / prelude.gl
index 8315b6f..de2a422 100644 (file)
@@ -54,6 +54,11 @@ pure function wrap (wrapper, xs) = @{
 #----------------------------------------------------------------------
 # Text functions.
 
+# Join two lists.
+pure function join (xs, ys) returning strings = @{
+    for f in %xs %ys; do echo "$f"; done
+}
+
 # Sort + uniq a list.
 pure function sort (xs) returning strings = @{
     for f in %xs; do echo "$f"; done | sort -u
@@ -69,6 +74,22 @@ pure function subst (from, to, text) returning string = @{
 #----------------------------------------------------------------------
 # File functions.
 
+# Base name.
+pure function basename (name) returning string = @{
+    basename %name
+}
+
+# Directory name.
+pure function dirname (name) returning string = @{
+    dirname %name
+}
+
+# File extension.
+pure function extension (name) returning string = @{
+    name=%name
+    echo "${name##*.}"
+}
+
 # Expand a wildcard into a list of filenames.
 #
 # This function is probably not "pure" since it depends on the