December 10th, 2013, 05:46 PM

Haskell help  beginer need help
Can someone write me the program for this: insert' 111 2 1 [[2..4],[3..5],[7..9]] = [[2, 3, 4],[3, 4, 111],[7, 8, 9]]
And a program for rotating the list for i places. Positive i rotates left for i places and negative rotates right for i places. Don't use Data.Bits
And also this: And also a function that is inserting an element on a i position in list , counting from 0, so that it replaces the existing element in the position i. If i is negative then the counting starts from the end of the list. The result must look like this:
insert2' "fine" 2 ["I","am","great"] = ["I","am","fine"] insert2i 3 (7) [1..4] = [1,3,3,4]
these last one i tried to do like this:
insert2' :: a > Int > [a] > [a]
insert2' x n [] = []
insert2' x n xs = f ++ [x] ++ drop (length xs  n) xs
where f = (take (length xs  n) xs)
December 10th, 2013, 06:11 PM

Hi,
Originally Posted by boba22
Can someone write me the program for this:
No. We don't do your homework, we don't help people cheat, and we don't drag students through highschool.
We can help you sort your thougths and fix bugs, but if you expect others to do the work while you take a rest, this won't work out.
OK, so you already tried something. What's the problem with that? Is there an error? An unexpected result?
December 10th, 2013, 06:16 PM

This one work :
insert' x n xs = first ++ [x] ++ drop 1 rest where (first, rest) = splitAt n xs
i only have problem with starting from the 0 position, how can i do that?
and in the first one, how can i set up list in list, i tryed like this:
insert' xs ys = [[x y  x < xs]  y < ys]
December 10th, 2013, 08:26 PM

You should do the tasks one at a time.
Originally Posted by boba22
insert' x n xs = first ++ [x] ++ drop 1 rest where (first, rest) = splitAt n xs
i only have problem with starting from the 0 position, how can i do that?
What problem? And what do you mean by "starting from the 0 position"? That the list index starts at 0? Doesn't it do that already?
Also, please, please start to use [ CODE ] tags. Haskell is whitespacesensitive, which means the formatting of the code is actually relevant.