2007-01-29 14:23:09 +00:00
|
|
|
with builtins;
|
|
|
|
|
2006-09-22 15:29:21 +00:00
|
|
|
rec {
|
|
|
|
|
|
|
|
fold = op: nul: list:
|
|
|
|
if list == []
|
|
|
|
then nul
|
2007-01-29 14:23:09 +00:00
|
|
|
else op (head list) (fold op nul (tail list));
|
2006-09-22 15:29:21 +00:00
|
|
|
|
|
|
|
concat =
|
|
|
|
fold (x: y: x + y) "";
|
|
|
|
|
|
|
|
flatten = x:
|
2007-01-29 14:23:09 +00:00
|
|
|
if isList x
|
2006-09-22 15:29:21 +00:00
|
|
|
then fold (x: y: (flatten x) ++ y) [] x
|
|
|
|
else [x];
|
|
|
|
|
2007-01-29 14:23:09 +00:00
|
|
|
sum = fold (x: y: add x y) 0;
|
|
|
|
|
|
|
|
hasSuffix = ext: fileName:
|
|
|
|
let lenFileName = stringLength fileName;
|
|
|
|
lenExt = stringLength ext;
|
|
|
|
in !(lessThan lenFileName lenExt) &&
|
|
|
|
substring (sub lenFileName lenExt) lenFileName fileName == ext;
|
2006-09-22 15:29:21 +00:00
|
|
|
|
|
|
|
}
|