Skip to content

Instantly share code, notes, and snippets.

@23Skidoo
Last active December 15, 2015 16:59
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 23Skidoo/5293171 to your computer and use it in GitHub Desktop.
Save 23Skidoo/5293171 to your computer and use it in GitHub Desktop.
Haskell as fast as C: A case study
-- 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
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