Guest User

Untitled

a guest
Dec 4th, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. let insert l a =
  2. if List.mem_assoc a l
  3. then
  4. let n = List.assoc a l in (a, n+1)::(List.remove_assoc a l)
  5. else (a, 1)::l
  6. ;;
  7. let for_each str f =
  8. let l = MultiSet.empty in
  9. let rec helper spot final =
  10. if spot = final then l
  11. else begin
  12. f l str.[spot];
  13. helper (spot + 1) final
  14. end
  15. in
  16. helper 0 (String.length str);
Add Comment
Please, Sign In to add comment