Magicloud Magiclouds <[email protected]> writes: > Hi, > For example, I have an array [0..]. Now I want to take a sub list > that starts from index 0, and only contain 4 odds, and is minimum > result. The answer should be [0, 1, 2, 3, 4, 5, 6, 7]. > How to do that? Combining lazy computing, I cannot figure out an > efficient algorithm.
Does f bound odds_so_far [] = [] f bound odds_so_far (x:xs) | odds_so_far == bound = [] | otherwise = x : f bound (odds_so_far + if odd x then 1 else 0) xs required_funciton = f 4 0 meet your criteria, or am I missing something? -- Jón Fairbairn [email protected] _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
