
Hi, all I wrote function that delete elements from list by indexes: delIndexes::[Int]->[a]->[a] delIndexes [] list = list delIndexes _ [] = [] delIndexes indexes list = take x list ++ delIndexes ( map (\y->y-x-1) xs ) ( drop (x+1) list( where )x:xs)=sort indexes There is problem that in each step of recursion this function sort list of indexes ( in last line) How can I write this code that sorting will be executed only once (in first step)? Thank you, Nadav

On Tue, Nov 09, 2010 at 06:14:49PM +0200, Nadav Chernin wrote:
There is problem that in each step of recursion this function sort list of indexes ( in last line)
How can I write this code that sorting will be executed only once (in first step)?
Just write a helper function that does all the actual work, and have delIndexes pass it a sorted index list as input: delIndexes inds l = delIndexes' (sort ind) l where delIndexes' ... -Brent
participants (2)
-
Brent Yorgey
-
Nadav Chernin