Last active
August 29, 2015 13:55
-
-
Save tonyday567/8777863 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| literate haskell test | |
| > {-# LANGUAGE RankNTypes, KindSignatures #-} | |
| > module ArcChallenge where | |
| > | |
| > import Control.Applicative | |
| > module ArcChallenge where | |
| > | |
| > import Control.Applicative | |
| > module ArcChallenge where | |
| > | |
| > import Control.Applicative | |
| > -- a comment | |
| > const int outputLength = M + N - 1; | |
| > int *y = new int[outputLength](); | |
| > for (int i = 0; i < outputLength; ++i) { | |
| > for (int j = 0; j < M; ++j) { | |
| > if (i - j >= 0) | |
| > y[i] += x[i - j] * h[j]; | |
| > } | |
| > } | |
| > convolve :: (Num a) => [a] -> [a] -> [a] | |
| > convolve hs xs = | |
| > let pad = replicate ((length hs) - 1) 0 | |
| > ts = pad ++ xs | |
| > in map (sum . zipWith (*) (reverse hs)) (init $ tails ts) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment