diff options
Diffstat (limited to 'cppawk-cons.1')
-rw-r--r-- | cppawk-cons.1 | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/cppawk-cons.1 b/cppawk-cons.1 index 86393c1..64939af 100644 --- a/cppawk-cons.1 +++ b/cppawk-cons.1 @@ -107,7 +107,7 @@ cons \- Lisp-like data representation and control flow macros \fI// Field/list conversion\fP - fields() \fI// convert Awk positional fields to list\fP + fields([\fIi \fP[, \fIn\fP]]) \fI// convert Awk positional fields to list\fP set_fields(\fIx\fP) \fI// set Awk positional fields from list x\fP \fI// list iteration\fP @@ -1970,10 +1970,10 @@ or unboxed objects. .bk .SS Functions \fIfields\fP and \fIset_fields\fP .bk -Syntax: +.B Syntax: .ft B - fields() + fields([\fIi \fP[, \fIn\fP]]) set_fields(\fIx\fP) .ft R @@ -1981,10 +1981,33 @@ Syntax: The .B fields -function returns a list of the current values of the Awk positional fields from -.B $1 +function converts a range of the current values of the Awk positional fields +into a list, which it returns. The function turns its arguments into an +abstract range of field indices to visit. Any field numbers which lie outside +of the valid range 1 to +.B NF +are clipped from this range, and the remaining fields are accessed and included +in the returned list. + +The +.I i +parameter indicates the starting field. If an argument isn't given, +it defaults to 1. It may be zero, or negative. Note that the record +.B $0 +isn't considered to be a field; this function does not access +.BR $0 . + +The +.I n +argument gives the number of fields to include in the list, starting at +.IR i . +If omitted, it defaults to including all of the fields from +.I i to -.BR $NF . +.BR NF . +If +.B n +is less than 1, the empty list is returned. The .B set_fields @@ -2013,6 +2036,12 @@ contains boxed values, then those boxed values become fields. fields() -> ("the" "quick" "brown" "fox") + \fI// range [-1, 2] is clipped to [1, 2]\fB + fields(-1, 4) -> ("the" "quick") + + \fI// range [3, 10] is clipped to [3, 4]\fB + fields(3, 7) -> ("brown" "fox") + set_fields(list(1, cons(1, 2), "foo", box_str("foo"))) \fI// this loop now prints:\fP |