-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fix: [generic + sort] All ready for generics #483
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
fix: [generic + sort] All ready for generics #483
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore this lol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
…rwara99/Go into feature/generics-interfaces
func Count(data []int) []int { | ||
import "github.com/TheAlgorithms/Go/constraints" | ||
|
||
func Count[T constraints.Number](data []int) []int { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why isn't this
func Count[T constraints.Number](data []T) []T {
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Primarily because I missed it... Feel free to open a PR to rectify it.
Beginning of Generics in Go. A relatively simple PR to include some examples use cases of Generics in sort. Was not able to actually convert some of the sort algorithms due to their intrinsic dependence on type
int
.