自分なりに、丁寧にたどってみた。
split :: [a]->[([a],[a])]
split[] =[]
split[_]=[]
split (x:xs) = ([x],xs) : [(x : ls , rs) | ( ls , rs ) <- split xs]
split [4]=[]
split [3,4]= ([3],[4]): [(3 : ls , rs) | ( ls , rs ) <- split [4]]
=([3],[4]): [(3: ls , rs) | ( ls , rs ) <- []] = ([3],[4])
split [2,3,4]=([2],[3,4]): [(2 : ls , rs) | ( ls , rs ) <- ([3],[4]) ]
==([2],[3,4]): [(2 :[3] ,[4]) ]= [([2],[3,4]),([2,3] ,[4]) ]
split [1,2,3,4]
=([1],[2,3,4]):[(1:ls,rs) | (ls,rs)<- [([2],[3,4]),([2,3] ,[4]) ] ]
=([1],[2,3,4]):[(1:[2],[3,4]),(1:[2,3],[4])]
=([1],[2,3,4]):[[1,2],[3,4]),([1,2,3],[4])]
という感じでいいのだろうか
0 件のコメント:
コメントを投稿