2007-01-29 16:23:09 +02:00
|
|
|
with builtins;
|
|
|
|
|
2006-09-22 18:29:21 +03:00
|
|
|
rec {
|
|
|
|
|
|
|
|
fold = op: nul: list:
|
|
|
|
if list == []
|
|
|
|
then nul
|
2007-01-29 16:23:09 +02:00
|
|
|
else op (head list) (fold op nul (tail list));
|
2006-09-22 18:29:21 +03:00
|
|
|
|
|
|
|
concat =
|
|
|
|
fold (x: y: x + y) "";
|
|
|
|
|
|
|
|
flatten = x:
|
2007-01-29 16:23:09 +02:00
|
|
|
if isList x
|
2006-09-22 18:29:21 +03:00
|
|
|
then fold (x: y: (flatten x) ++ y) [] x
|
|
|
|
else [x];
|
|
|
|
|
2007-01-29 16:23:09 +02: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 18:29:21 +03:00
|
|
|
|
|
|
|
}
|