public
Last active

Haskell as fast as C: A case study

  • Download Gist
MicroOpt.hs
Haskell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
-- 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
Vec.hs
Haskell
1 2 3 4 5 6 7
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)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.