stdlib: Implement last() and nth() functions.
[goals.git] / docs / Goalfile.pod
index 40ca73a..f586ec4 100644 (file)
@@ -30,6 +30,14 @@ For example:
 
 Returns the directory part of the path.
 
 
 Returns the directory part of the path.
 
+=head3 error (msg)
+
+For example:
+
+ error ("this should not happen")
+
+This prints the error message and causes goals to exit.
+
 =head3 extension (filename)
 
 For example:
 =head3 extension (filename)
 
 For example:
@@ -38,6 +46,32 @@ For example:
 
 Returns the filename extension.
 
 
 Returns the filename extension.
 
+=head3 filter (pattern, list)
+
+For example:
+
+ filter ("a+", ["a", "b", "ca"]) ⇒ ["a", "ca"]
+
+Filter a list returning only the elements that match the extended
+regular expression C<pattern>.
+
+=head3 filter-out (pattern, list)
+
+For example:
+
+ filter-out ("a+", ["a", "b", "ca"]) ⇒ ["b"]
+
+Filter a list returning only the elements that I<do not> match the
+extended regular expression C<pattern>.
+
+=head3 head (list)
+
+For example:
+
+ head (["a", "b", "c"]) ⇒ "a"
+
+Returns the head (first) element of the list.
+
 =head3 join (list1, list2)
 
 For example:
 =head3 join (list1, list2)
 
 For example:
@@ -48,6 +82,39 @@ Concatenate C<list1> and C<list2>.  It's not usually necessary to use
 this function since goals automatically flattens lists within lists
 into simple lists in many cases.
 
 this function since goals automatically flattens lists within lists
 into simple lists in many cases.
 
+=head3 last (list)
+
+For example:
+
+ last (["a", "b", "c"]) ⇒ "c"
+
+Returns the last element of a list.
+
+=head3 nth (n, list)
+
+For example:
+
+ nth (1, ["a", "b", "c"]) ⇒ "b"
+
+Returns the n’th element of a list (counting from 0).
+
+=head3 read (filename)
+
+For example:
+
+ read ("filename") => "this is the content of filename"
+
+Read the contents of C<filename> and return it as a single string.
+If there is a trailing C<\n> in the file it is truncated.
+
+=head3 readlines (filename)
+
+For example:
+
+ readlines ("filename") => ["line1", "line2", "line3"]
+
+Read the lines in C<filename> returning a list of strings.
+
 =head3 realpath (filename)
 
 For example:
 =head3 realpath (filename)
 
 For example:
@@ -76,6 +143,14 @@ This function works something like make’s C<subst> function, except
 that C<from> is a regular expression, specifically a L<sed(1)>
 extended regular expression.
 
 that C<from> is a regular expression, specifically a L<sed(1)>
 extended regular expression.
 
+=head3 tail (list)
+
+For example:
+
+ tail (["a", "b", "c"]) ⇒ ["b", "c"]
+
+Returns the tail (all except first) elements of the list.
+
 =head3 wildcard (pattern)
 
 For example:
 =head3 wildcard (pattern)
 
 For example: