IO
Size: a a a
[
[
[
[
IO
-A
replicateOnePass :: [Int] -> [Int]N = 10000, default rtsopts
replicateOnePass xs = replicate l m
where
!(Sum !l, Min !m) = foldMap' (const 1 &&& Min) xs
benchmarking foldl' by @aadaa_fgtaa 76.14 μs (75.92 μs .. 76.49 μs)N = 1000000, default rtsopts
benchmarking recursive strict by @kana_sama 132.3 μs (132.2 μs .. 132.5 μs)
benchmarking fix strict by @lierdakil 146.5 μs (146.1 μs .. 146.8 μs)
benchmarking naiveReplace 146.6 μs (145.9 μs .. 147.5 μs)
benchmarking naiveReplicate 173.6 μs (173.3 μs .. 174.0 μs)
benchmarking replicateOnePass 94.46 μs (94.43 μs .. 94.50 μs)
benchmarking foldl' by @aadaa_fgtaa 59.86 ms (57.15 ms .. 62.37 ms)N = 1000000, -A128M
benchmarking recursive strict by @kana_sama 82.99 ms (77.61 ms .. 88.86 ms)
benchmarking fix strict by @lierdakil 99.61 ms (93.52 ms .. 105.5 ms)
benchmarking naiveReplace 15.51 ms (15.23 ms .. 15.96 ms)
benchmarking naiveReplicate 14.30 ms (14.05 ms .. 14.61 ms)
benchmarking replicateOnePass 10.31 ms (10.29 ms .. 10.33 ms)
benchmarking foldl' by @aadaa_fgtaa 12.90 ms (12.71 ms .. 13.12 ms)
benchmarking recursive strict by @kana_sama 22.48 ms (21.97 ms .. 23.18 ms)
benchmarking fix strict by @lierdakil 24.12 ms (23.79 ms .. 24.53 ms)
benchmarking naiveReplace 21.54 ms (21.33 ms .. 21.77 ms)
benchmarking naiveReplicate 22.23 ms (21.10 ms .. 23.31 ms)
benchmarking replicateOnePass 13.77 ms (13.56 ms .. 14.00 ms)
IO
replicateOnePass :: [Int] -> [Int] =
\r [xs_s7tE]
let-no-escape {
$w$j_s7tF :: Int# -> Int# -> [Int] =
\r [ww_s7tG ww1_s7tH]
case <# [0# ww_s7tG] of {
__DEFAULT -> [] [];
1# ->
let { m_s7tJ :: Int = CCCS I#! [ww1_s7tH]; } in
let {
Rec {
$wxs_s7tK :: Int# -> [Int] =
\r [ww2_s7tL]
case ww2_s7tL of ds1_s7tM {
__DEFAULT ->
let {
sat_s7tO :: [Int] =
\u []
case -# [ds1_s7tM 1#] of sat_s7tN {
__DEFAULT -> $wxs_s7tK sat_s7tN;
};
} in : [m_s7tJ sat_s7tO];
1# -> : [m_s7tJ []];
};
end Rec }
} in $wxs_s7tK ww_s7tG;
};
} in
let-no-escape {
Rec {
$wgo1_s7tP :: [Int] -> Int# -> Int# -> [Int] =
\r [w_s7tQ ww_s7tR ww1_s7tS]
case w_s7tQ of {
[] -> $w$j_s7tF ww_s7tR ww1_s7tS;
: y_s7tU ys_s7tV ->
case y_s7tU of {
I# y1_s7tX ->
case <=# [ww1_s7tS y1_s7tX] of {
__DEFAULT ->
case +# [ww_s7tR 1#] of sat_s7tZ {
__DEFAULT -> $wgo1_s7tP ys_s7tV sat_s7tZ y1_s7tX;
};
1# ->
case +# [ww_s7tR 1#] of sat_s7u0 {
__DEFAULT -> $wgo1_s7tP ys_s7tV sat_s7u0 ww1_s7tS;
};
};
};
};
end Rec }
} in $wgo1_s7tP xs_s7tE 0# 9223372036854775807#;
[
VS
VS
[
[
VS
[
Prelude> update as n a = (fst $ splitAt n as) ++ [(head $ snd $ splitAt n as) + a] ++(tail $ snd $ splitAt n as)^ 6 + 7
Prelude> update [1..10] 5 7
[1,2,3,4,5,13,7,8,9,10]
[
[