Skip to content

Instantly share code, notes, and snippets.

@chaoxu
Created December 6, 2011 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chaoxu/1438136 to your computer and use it in GitHub Desktop.
Save chaoxu/1438136 to your computer and use it in GitHub Desktop.
import Data.List
rec :: Num a => [a] -> [a] -> [Int] -> [a]
rec c b m = a
where a = c++rest
rest = next [] 0 m
next xs k (m:ms)
| k == m = next (a:xs) k ms
| otherwise = val ++ next (map tail xs) (k+1) (m:ms)
where val = if (k<length c) then [] else [sum $ zipWith (*) (reverse (map head xs)) b]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment