Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let path = {|/bin:/usr/bin:/home/user/horrible\:path|}
- let should_escape char_stack c =
- not (Stack.is_empty char_stack)
- && Stack.top char_stack = "\\"
- let a char_stack c =
- Stack.push (
- (
- if (should_escape char_stack c)
- then (Stack.pop char_stack)
- else ""
- ) ^ (String.make 1 c)
- ) char_stack ;
- char_stack
- let proto_paths = String.fold_left a (Stack.create()) path
- let b string_stack c =
- Stack.push (
- if c = ":"
- then ""
- else (Stack.pop string_stack) ^ c
- ) string_stack ;
- string_stack
- let paths = Stack.fold b (Stack.create()) proto_paths
- let () = Stack.iter print_endline paths
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement