Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let rec appendtolist l a =
- match l with
- |[] -> [a]
- |h :: t -> (h :: appendtolist t a)
- ;;
- let take n words =
- let rec loop i l1 =
- if i = n
- then l1
- else
- if( n <= List.length words ) then
- loop (i + 1) ( appendtolist l1 (List.nth words i) )
- else []
- in loop 0 []
- ;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement