daily pastebin goal


a guest Apr 16th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. mergesort list = if length list < 2
  2.                  then list
  3.                  else let half  = length list / 2
  4.                           left  = take half list  # take zoberie prvych half prvkov z listu a zahodi zvysok
  5.                           right = drop half list  # drop utrhne prvych half prvkov z listu a vrati zvysok
  6.                       in
  7.                           merge (mergesort left) (mergesort right)
  9. merge [] right   = right
  10. merge left []    = left
  11. merge left right = if first left < first right                       # first vrati prvy prvok zoznamu
  12.                    then cons (first left) (merge (rest left) right)  # rest vrati zvysok zoznamu okrem prveho prvku
  13.                    else cons (first right) (merge left (rest right)) # cons prida prvok na zaciatok zoznamu
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand