Advertisement
Guest User

Untitled

a guest
Dec 15th, 2016
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. let rec appendtolist l a =
  2. match l with
  3. |[] -> [a]
  4. |h :: t -> (h :: appendtolist t a)
  5. ;;
  6.  
  7. let take n words =
  8. let rec loop i l1 =
  9. if i = n
  10. then l1
  11. else
  12. if( n <= List.length words ) then
  13. loop (i + 1) ( appendtolist l1 (List.nth words i) )
  14. else []
  15. in loop 0 []
  16. ;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement