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