home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Caml Light 0.61 / Source / src / lib / pair.ml < prev    next >
Encoding:
Text File  |  1993-09-24  |  585 b   |  27 lines  |  [TEXT/MPS ]

  1. #open "exc";;
  2.  
  3. let rec split = function
  4.          []    -> [],[]
  5.   | (x1,x2)::l -> let (l1,l2) = split l in (x1::l1,x2::l2)
  6. ;;
  7.  
  8. let rec combine = function
  9.         [],[]     -> []
  10.   | h1::t1,h2::t2 -> (h1,h2)::combine (t1,t2)
  11.   |       _        -> invalid_arg "combine"
  12. ;;
  13.  
  14. let map_combine f =
  15.   map where rec map = function
  16.     [], [] -> []
  17.   | h1::t1, h2::t2 -> f (h1,h2) :: map (t1,t2)
  18.   | _ -> invalid_arg "map_combine"
  19. ;;
  20.  
  21. let do_list_combine f =
  22.   dol where rec dol = function
  23.     [], [] -> ()
  24.   | h1::t1, h2::t2 -> f (h1,h2); dol (t1,t2)
  25.   | _ -> invalid_arg "do_list_combine"
  26. ;;
  27.