Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for other variable names #4

Open
anupshinde opened this issue Jan 16, 2017 · 0 comments
Open

Support for other variable names #4

anupshinde opened this issue Jan 16, 2017 · 0 comments

Comments

@anupshinde
Copy link

Great work!

You might want to add a line in the README to allow multiple variable names. I had a hard time figuring out why anything other than "x", "y","z" won't work.

https://github.com/rogeralsing/go-genetic-math/blob/master/ast/mutate.go#L11

For anybody who's looking:
To support other variable names, I modified

var letterRunes = []rune("xyz")

func randomLetter() string {
	return string(letterRunes[rand.Intn(len(letterRunes))])
}

to


var variableNames = []string{} // or []string{"x", "y", "z"}

func randomLetter() string {
	return variableNames[rand.Intn(len(variableNames))]
}

// registering variable names externally - if required
func RegisterInputVarName(variableName string) {
	variableNames = append(variableNames, variableName)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants