Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
e9b051238This file is pinned to the selected release. Download the original to open it in your design tool.
{
init (Cons x []) = [];
init (Cons x (Cons y ys)) = Cons x (init (Cons y ys));
inits xs = case xs of {
[] -> Cons [] [];
Cons y ys -> Cons xs (inits (init xs));
};
tails [] = [];
tails (Cons x xs) = Cons (Cons x xs) (tails xs);
map f [] = [];
map f (Cons x xs) = Cons (f x) (map f xs);
append [] ys = ys;
append (Cons x xs) ys = Cons x (append xs ys);
concatMap f [] = [];
concatMap f (Cons x xs) = append (f x) (concatMap f xs);
segments xs = concatMap tails (inits xs);
maximum (Cons x xs) = max x xs;
max m [] = m;
max m (Cons x xs) = case (<=) m x of { True -> max x xs ; False -> max m xs };
sum [] = 0;
sum (Cons x xs) = (+) x (sum xs);
mss xs = maximum (map sum (segments xs));
fromTo n m = case (<=) n m of {
True -> Cons n (fromTo ((+) n 1) m);
False -> [];
};
main = emitInt (mss (fromTo ((-) 0 150) 150)) 0;
}