Advertisement
Guest User

Untitled

a guest
Jun 16th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. main = return ()
  2.  
  3. getElements list =
  4.  case list of
  5.  h:t -> if length list == 1 then
  6.          []
  7.         else
  8.          [h]++getElements t
  9.  _   -> []
  10.  
  11. palindrom list left right =
  12.  if left>=right then
  13.   1
  14.  else
  15.  if list !! left == list !! right then
  16.     palindrom list (left+1) (right-1)
  17.  else
  18.   -1
  19.  
  20. splosci list =
  21.  case list of
  22.   [] -> []
  23.   h:t -> h++(splosci t)
  24.  
  25. getEl2 list from to =
  26.  if from == to then
  27.    []
  28.  else
  29.    [list !! from] ++ (getEl2 list (from+1) to)
  30.    
  31. swapElements list i j =
  32.  if i == j then
  33.   list
  34.  else if i < j then
  35.   (getEl2 list 0 i)++[list !! j]++(getEl2 list (i+1) j)++[list !! i]++(getEl2 list (j+1) (length list))
  36.  else
  37.   (getEl2 list 0 j)++[list !! i]++(getEl2 list (j+1) i)++[list !! j]++(getEl2 list (i+1) (length list))
  38.  
  39. createList n e =
  40.  if e == (n-1) then
  41.   [e]
  42.  else
  43.  [e]++(createList n (e+1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement