お題: 関数引数の permutation
面白かった。
permArgs n f = map ($ f) $ g n g [] = [id] g xxs@(x:xs) = [r . j| r <- subs xxs, j <- g xs] subs xs = scanl (flip (.)) id xs suc n = flip: map (.) n one = [] two = suc one three = suc two four = suc three five = suc four
追記(2004-12-11)
ん?
permArgs 3 は permArgs3 と同等であり、permArgs 5 は permArgs5 と同等であるものとする
ってことは少なくとも整数リテラルを取れないといけないのか。型付けできるのだろうか。