Created
October 15, 2016 01:06
-
-
Save lisp-ceo/1735d94d185edc2c4b8207414abdcd13 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 expand(s string, f func(string) string) string { | |
if len(s) < len(FOO) { | |
return s | |
} | |
for i := strings.Index(s, FOO); i != -1; i = strings.Index(s, FOO){ | |
t := s[:i] | |
t = t + f(s[i+1:i+len(FOO)]) | |
t = t + s[i+len(FOO):] | |
s = t | |
} | |
return s | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What I want is a C-style while loop but when I run it as
for i := strings.Index(s, FOO) {}
it gives a compilation error saying the function is used as a value.