おまけ(´ー`)

  • (take,drop)の形から([a],[a])の形を返すように微調整したバージョン
splitAt5' = 
 curry((\[x,y]->(x,y)).(uncurry (flip((flip((flip(map) . flip(map)
   (map($ take,drop)) [fst,snd]) . flip($)))).flip($)))))
  • 実行結果
*Main> :! type mysplit.hs
splitAt' n = flip(map)  (flip(map) [take,drop] ($ n)) . flip($)

splitAt2' n =  (flip(map) . flip(map) [take,drop] . flip($)) n.flip($)

splitAt3' = flip((flip((flip(map) . flip(map) [take,drop] . flip($)))).flip($) )

splitAt4' = flip((flip((flip(map) . flip(map) (map ($ (take,drop)) [fst,snd]) .
flip($)))).flip($) )

splitAt5' = curry((\[x,y]->(x,y)).(uncurry (flip((flip((flip(map) . flip(map) (m
ap ($ (take,drop)) [fst,snd]) . flip($)))).flip($) ))))
*Main> :l mysplit.hs
Compiling Main             ( mysplit.hs, interpreted )
Ok, modules loaded: Main.
*Main> splitAt5' 10 ['a'..'z']
("abcdefghij","klmnopqrstuvwxyz")

curryやuncurryを使ってるのは

2引数を1引数に変換

 (f x y ::Int->[a]->[[a],[a]])→(g (x,y) :: (Int,[a])->[[a],[a]] ) 

関数合成をする

 (\[x,y]->(x,y)) . g(x,y) :: (Int,[a])->([a],[a]) )

1引数を2引数に戻す

 (g'(x,y)::(Int,[a])->([a],[a]) → f' x y ::Int->[a]->([a],[a]) )

つまり関数合成のための引数合わせ。