f::fold1 (public)
f::fold1 f xs
Defined in packages/acs-tcl/tcl/ad-functional-procs.tcl
Takes a binary function f and a list {x1 x2 x3 ...} and returns (...(f (f (f x1 x2) x3) x4)...).
"fold1" behaves like "fold", but does not take a start element and does not work for empty lists.
Examples
fold1 min [list 3 1 4 1 5 9 2 6] = 1
fold1 max [list 3 1 4 1 5 9 2 6] = 9
- Parameters:
- f
xs
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: if { [null_p $xs] } { error "ERROR: fold1 is undefined for empty lists." } else { fold $f [head $xs] [tail $xs] }XQL Not present: Generic, PostgreSQL, Oracle