Skip to content

Instantly share code, notes, and snippets.

@tonyday567
Last active August 29, 2015 13:55
Show Gist options
  • Select an option

  • Save tonyday567/8777863 to your computer and use it in GitHub Desktop.

Select an option

Save tonyday567/8777863 to your computer and use it in GitHub Desktop.
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