Last active
December 15, 2015 16:59
-
-
Save 23Skidoo/5293171 to your computer and use it in GitHub Desktop.
Haskell as fast as C: A case study
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
-- http://lambda.jstolarek.com/2013/04/haskell-as-fast-as-c-a-case-study/#comment-901 | |
$s$wfoldlM'_loop_s153 = | |
\ (sc_s14X :: Int#) (sc1_s14Y :: Int#) -> | |
case >=# sc1_s14Y ipv1_s11g of _ { | |
False -> | |
case indexIntArray# | |
ipv2_s11h (+# ipv_sZN sc1_s14Y) | |
of wild_a13W { __DEFAULT -> | |
$s$wfoldlM'_loop_s153 | |
(+# | |
sc_s14X | |
(*# | |
(*# | |
(word2Int# | |
(and# (int2Word# wild_a13W) (__word 1))) | |
wild_a13W) | |
wild_a13W)) | |
(+# sc1_s14Y 1) | |
}; | |
True -> sc_s14X | |
}; } in |
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 Vec where | |
import qualified Data.Vector.Unboxed as U | |
import Data.Bits | |
sumSqrV :: U.Vector Int -> Int | |
sumSqrV = U.sum . U.map (\x -> (x .&. 1) * x * x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment