Skip to content

Instantly share code, notes, and snippets.

@kuanyingchou
Created June 22, 2014 03:16
Show Gist options
  • Save kuanyingchou/08f988733b96879ca05b to your computer and use it in GitHub Desktop.
Save kuanyingchou/08f988733b96879ca05b to your computer and use it in GitHub Desktop.
{-
題 物件數
1~2題 2
3~4題 3
5~6題 4
7~8題 5
9~10題 6
11~20題 6
-}
objNum = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]
objNum' = [ 2, 2, 3, 3, 4,
4, 5, 5, 6, 6,
6, 6, 6, 6, 6,
6, 6, 6, 6, 6 ]
objNum'' = replicate 2 2 ++ replicate 2 3 ++ replicate 2 4 ++
replicate 2 5 ++ replicate 2 6 ++ replicate 10 6
objNum''' = concat [replicate x y | (x, y) <- [(2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (10, 6)]]
objNum'''' = concat [
q 1 2 2,
q 3 4 3,
q 5 6 4,
q 7 8 5,
q 9 10 6,
q 11 20 6 ]
where q x y z = [ z | _ <- [x..y] ]
q' (x, y, z) = [z | _ <- [x..y]]
objNum''''' = map q' [
(1, 2, 2),
(3, 4, 3),
(5, 6, 4),
(7, 8, 5),
(9, 10, 6),
(11, 20, 6)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment