#----------------------------------------------------------------------
# Basic functions.
+function error (msg) = @{
+ echo %msg >&2
+ exit 1
+}
+
# Wrap list of strings in a call or tactic.
pure function wrap (wrapper, xs) = @{
echo '['
#----------------------------------------------------------------------
# Text functions.
+# Head of a list.
+pure function head (xs) returning string = @{
+ for f in %xs; do
+ echo "$f"
+ exit 0
+ done
+}
+
# Join two lists.
pure function join (xs, ys) returning strings = @{
for f in %xs %ys; do echo "$f"; done
echo %text | sed -E s/%from/$to/g
}
+# Tail of a list.
+pure function tail (xs) returning strings = @{
+ drop=1
+ for f in %xs; do
+ if [ -z "$drop" ]; then echo "$f"; fi
+ drop=
+ done
+}
+
#----------------------------------------------------------------------
# File functions.
echo "${name##*.}"
}
+# Read a file.
+function read (filename) returning string = @{
+ cat %filename
+}
+
+# Read a file as a list of lines.
+function readlines (filename) returning strings = @{
+ cat %filename
+}
+
+# Real path.
+function realpath (filename) returning string = @{
+ realpath -- %filename
+}
+
# Expand a wildcard into a list of filenames.
#
# This function is probably not "pure" since it depends on the