diff options
-rw-r--r-- | lib.c | 9 | ||||
-rw-r--r-- | txr.1 | 14 |
2 files changed, 17 insertions, 6 deletions
@@ -559,10 +559,13 @@ loc lastcons(val list) return ret; } -val last(val list) +val last(val seq) { - loc p = lastcons(list); - return nullocp(p) ? list : deref(p); + if (listp(seq)) { + loc p = lastcons(seq); + return nullocp(p) ? seq : deref(p); + } + return sub(seq, negone, t); } val nthcdr(val pos, val list) @@ -14850,11 +14850,11 @@ See the relevant examples below. .coNP Function @ last .synb -.mets (last << list ) +.mets (last << seq ) .syne .desc If -.meta list +.meta seq is a nonempty proper or improper list, the .code last function @@ -14863,13 +14863,21 @@ returns the last cons cell in the list: that cons cell whose field is a terminating atom. If -.meta list +.meta seq is .codn nil , then .code nil is returned. +If +.meta seq +is a non-list sequence, then a one-element suffix of +.code seq +is returned, or an empty suffix if +.code seq +is an empty sequence. + .coNP Accessor @ nthcdr .synb .mets (nthcdr < index << list ) |