```こんにちは。早川です。
-- 年度末はやっぱり忙しいですね

On Fri, 21 Mar 2003 14:54:21 +0900
"TOYOFUKU Chikanobu" <ttoyofukujp / yahoo.co.jp> wrote:
> >                individual    inherited
> > COST CENTRE   %time %alloc   %time %alloc
>   ...
> >    rtailn       0.0    2.8     0.0    2.8
>
>   GHC では最適化されているんですかね。
>   reverse.(ttailn n).reverse だとどうなりますか。

take と比較するため take' と take'' を用意して

rtailn :: Int -> [a] -> [a]
rtailn n = reverse . (take n) . reverse

rtailn' :: Int -> [a] -> [a]
rtailn' n xs = reverse \$! take n \$! reverse \$! xs
-- これで比較の対照になるでしょうか

ttailn :: Int -> [a] -> [a]
ttailn n ls = difftail ls (drop n ls)
where difftail hs []         = hs
difftail (_:hs) (_:ts) = difftail hs ts

take' = take

take'' :: Int -> [a] -> [a]
take'' n = reverse . (ttailn n) . reverse

main = do
print (rtailn   3 [1..1000000])
print (rtailn'  3 [1..1000000])
print (ttailn   3 [1..1000000])
print (take'    3 [1..1000000])
print (take''   3 [1..1000000])

total time  =       16.10 secs   (805 ticks @ 20 ms)
total alloc = 180,010,040 bytes  (excludes profiling overheads)

individual    inherited
COST CENTRE  %time %alloc   %time %alloc
MAIN           0.0    0.0   100.0  100.0
main          0.0    0.0     0.0    0.0
CAF           0.0    0.0   100.0  100.0
main        70.1   80.0   100.0  100.0
take''      6.6    6.7    12.7    6.7
ttailn     6.1    0.0     6.1    0.0
take'       0.0    0.0     0.0    0.0
ttailn      5.5    0.0     5.5    0.0
rtailn'     5.7    6.7     5.7    6.7
rtailn      6.1    6.7     6.1    6.7
CAF           0.0    0.0     0.0    0.0

reverse.xxx.reverse での最適化は存在しないでしょうか。
-- また嘘を言ってしまったかも..

--
SH
tetryl / tokyoprogrammer.com

--