Created
July 13, 2015 19:09
-
-
Save jweinst1/451bb50245f7767d0d25 to your computer and use it in GitHub Desktop.
Function that can determine whether or not to add a character to a string based on some of the indexes of the string. Swift.
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
func indexstring(str: String, index: Int) ->Character { | |
var strlist = Array(str) | |
return strlist[index] | |
} | |
func addconorvow(str: String) ->String { | |
var modstr = str | |
if indexstring(str, 1) == "d" { | |
modstr += "d" | |
return modstr | |
} else { | |
modstr += "e" | |
return modstr | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment