Returns e to the power of <number>.
& EXTRACT()
- extract(<list>,<first>,<length>[,<delimiter>])
+ extract(<list>[,<first>[,<length>[,<delimiter>]]])
This function returns <length> elements of a list, counting
- from the <first> element.
+ from the <first> element. If <length> is not specified, the
+ default is 1, so extract(list,3) acts like elements(list,3).
+ If <first> is not specified, the default is the 1, so
+ extract(list) acts like first(list).
For example:
think extract(This is a test string,3,2)
{"EVAL", fun_eval, 2, 2, FN_REG},
{"ESCAPE", fun_escape, 1, -1, FN_REG},
{"EXIT", fun_exit, 1, 1, FN_REG},
- {"EXTRACT", fun_extract, 3, 4, FN_REG},
+ {"EXTRACT", fun_extract, 1, 4, FN_REG},
{"FILTER", fun_filter, 2, 4, FN_REG},
{"FILTERBOOL", fun_filter, 2, 4, FN_REG},
{"FINDABLE", fun_findable, 2, 2, FN_REG},
/* ARGSUSED */
FUNCTION(fun_extract)
{
- char sep;
- int start, len;
+ char sep = ' ';
+ int start = 1, len = 1;
char *s, *r;
if (!is_integer(args[1]) || !is_integer(args[2])) {
return;
}
s = args[0];
- start = parse_integer(args[1]);
- len = parse_integer(args[2]);
- if (!delim_check(buff, bp, nargs, args, 4, &sep))
+
+ if (nargs > 1) {
+ if (!is_integer(args[1])) {
+ safe_str(T(e_ints), buff, bp);
+ return;
+ }
+ start = parse_integer(args[1]);
+ }
+ if (nargs > 2) {
+ if (!is_integer(args[2])) {
+ safe_str(T(e_ints), buff, bp);
+ return;
+ }
+ len = parse_integer(args[2]);
+ }
+ if ((nargs > 3) && (!delim_check(buff, bp, nargs, args, 4, &sep)))
return;
if ((start < 1) || (len < 1))