diff options
author | Joe Zhao <ztuowen@gmail.com> | 2015-03-17 14:33:20 +0800 |
---|---|---|
committer | Joe Zhao <ztuowen@gmail.com> | 2015-03-17 14:33:20 +0800 |
commit | 18a639eb460d7581a5dd594a50eb236ae7675685 (patch) | |
tree | 85f4289e9835fbaa673256a941970313f56848b4 /h17.hs | |
parent | a9ee47b61558efe09aee23f5671aabd0c3747e8a (diff) | |
download | h99-18a639eb460d7581a5dd594a50eb236ae7675685.tar.gz h99-18a639eb460d7581a5dd594a50eb236ae7675685.tar.bz2 h99-18a639eb460d7581a5dd594a50eb236ae7675685.zip |
+16 +17 +18 +19
Diffstat (limited to 'h17.hs')
-rw-r--r-- | h17.hs | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -0,0 +1,10 @@ +split :: [a] -> Int -> ([a],[a]) +split xs c = splitHelper [] xs c + where + splitHelper pre nxt 0 = (reverse pre, nxt) + splitHelper pre (x:nxt) c = splitHelper (x:pre) nxt (c-1) + +split' (x:xs) c | c>0 = + let (pre,nxt) = split' xs (c-1) + in (x:pre,nxt) +split' xs _ = ([],xs) |