Guest User

Untitled

a guest
Nov 20th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. let combinations combine l l' =
  2. CCList.cartesian_product [l; l']
  3. |> CCList.map (fun [p; p'] -> combine p p')
  4.  
  5. let paths xmax ymax =
  6. let rec aux x y prev_paths =
  7. if x > xmax || y > ymax then []
  8. else if x = xmax && y = ymax then prev_paths
  9. else
  10. let next_paths = List.flatten [
  11. aux (x+1) y [[ `Right ]];
  12. aux x (y+1) [[ `Down ]];
  13. ] in
  14. combinations (@) prev_paths next_paths
  15. in
  16. aux 0 0 [[]]
Add Comment
Please, Sign In to add comment