|
Revision 1, 0.7 kB
(checked in by thesz, 2 years ago)
|
Initial commit
|
| Line | |
|---|
| 1 |
-- | Utils.hs |
|---|
| 2 |
-- Some handy function(s). |
|---|
| 3 |
-- |
|---|
| 4 |
-- Copytight (C) 2007, 2008 Serguey Zefirov |
|---|
| 5 |
-- |
|---|
| 6 |
-- This program is free software; you can redistribute it and/or modify |
|---|
| 7 |
-- it under the terms of the GNU General Public License as published by |
|---|
| 8 |
-- the Free Software Foundation; either version 3, or (at your option) |
|---|
| 9 |
-- any later version. |
|---|
| 10 |
-- See file COPYING or visit http://www.gnu.org/licenses for details. |
|---|
| 11 |
|
|---|
| 12 |
module Utils where |
|---|
| 13 |
|
|---|
| 14 |
splitLastN takeMax limit list |
|---|
| 15 |
| len < limit = (list,[]) |
|---|
| 16 |
| otherwise = splitAtEnd pos list |
|---|
| 17 |
where |
|---|
| 18 |
len = length list |
|---|
| 19 |
overflow = len - limit |
|---|
| 20 |
pos = min overflow takeMax |
|---|
| 21 |
splitAtEnd i list = (reverse t,reverse h) |
|---|
| 22 |
where |
|---|
| 23 |
(h,t) = splitAt i $ reverse list |
|---|