Advertisement
user_

I laughed

Dec 7th, 2011
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #
  2. # $(1): haystack
  3. # $(2): needle
  4. #
  5. # Guarantees that needle appears at most once in haystack,
  6. # without changing the order of other elements in haystack.
  7. # If needle appears multiple times, only the first occurrance
  8. # will survive.
  9. #
  10. # How it works:
  11. #
  12. # - Stick everything in haystack into a single word,
  13. # with "|||" separating the words.
  14. # - Replace occurrances of "|||$(needle)|||" with "||| |||",
  15. # breaking haystack back into multiple words, with spaces
  16. # where needle appeared.
  17. # - Add needle between the first and second words of haystack.
  18. # - Replace "|||" with spaces, breaking haystack back into
  19. # individual words.
  20. #
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement