Created
February 23, 2016 14:18
-
-
Save Betawolf/c88ec3e0e8be8eb676c6 to your computer and use it in GitHub Desktop.
Squash a string using filter() and a single call to string()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function squash(str) | |
lc = 0 | |
return string(filter(str) do x | |
if x != lc | |
lc = x | |
return true | |
end | |
return false | |
end) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment