fork(2) download
  1. import Data.List
  2.  
  3. r=reverse;s[]=[];s(h:t)=r h++s(map r t)
  4.  
  5. main =
  6. mapM_ print $ map s [
  7. [],
  8. [[1]],
  9. [[2, 1], [3, 4]],
  10. [[3, 2, 1], [4, 5, 6], [9, 8, 7]],
  11. [[4, 3, 2, 1], [5, 6, 7, 8], [12, 11, 10, 9], [13, 14, 15, 16]]
  12. ]
Success #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
[]
[1]
[1,2,3,4]
[1,2,3,4,5,6,7,8,9]
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]