Last active
October 16, 2015 08:03
-
-
Save christiaanb/c6e7d7ddcb7a6480fc43 to your computer and use it in GitHub Desktop.
This file contains 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
module BitPalindrome2 where | |
-- import Control.Arrow (second) | |
import CLaSH.Prelude | |
-- This function will be in `clash-prelude-0.10.1` | |
bv2v :: KnownNat n => BitVector n -> Vec n Bit | |
bv2v = unpack | |
evenPalindrome :: (Eq a,KnownNat m) | |
=> Vec (2*m) a | |
-> Bool | |
evenPalindrome v = l == reverse r | |
where | |
(l,r) = splitAtI v | |
topEntity :: BitVector 8 -> Bool | |
topEntity = evenPalindrome . bv2v | |
-- pointFreePalindrome :: (Eq a,KnownNat m) | |
-- => Vec (2*m) a | |
-- -> Bool | |
-- pointFreePalindrome = uncurry (==) . second reverse . splitAtI | |
-- topEntity :: BitVector 8 -> Bool | |
-- topEntity = pointFreePalindrome . bv2v |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment