You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can see the imperative code in sorting algorithm, I'm intending to add in functional way
for e.g. In MergeSort , I can see while loop which is an iterative approach -
while (k < high + 1) {
// must check if empty to avoid exceptions
if (i > left.length - 1) {
array(k) = right(j)
j = j + 1
} else if (j > right.length - 1) {
array(k) = left(i)
i = i + 1
} else if (left(i) <= right(j)) {
array(k) = left(i)
i = i + 1
} else {
array(k) = right(j)
j = j + 1
}
k = k + 1
}
Best Practice: In scala, we follow functional way to write it
def merge(xs: List[Int], ys: List[Int]): List[Int] = (xs, ys) match {
// If either list is empty, return the other list
case (Nil, _) => ys
case (_, Nil) => xs
// If the first element of xs is smaller than the first element of ys,
// append it to the result of merging the rest of xs with ys
case (x :: xtail, y :: ytail) =>
if (x < y) x :: merge(xtail, ys)
// Otherwise, append the first element of ys to the result of merging xs with the rest of ys
else y :: merge(xs, ytail)
}
I'll be creating a PR shortly to add functional code for sorting algorithm given in this repo.
@Panquesito7@andreicioban I just found exciting repo, I've suggested some enhancements and can be this be considered as a hacktoberfest contributions?
Hey there! Of course! I do not know Scala or maintain this repository except for cleanup and documentation, but of course, it can be considered for Hacktoberfest. 🙂
@Panquesito7@andreicioban I just found exciting repo, I've suggested some enhancements and can be this be considered as a hacktoberfest contributions?
Hey there! Of course! I do not know Scala or maintain this repository except for cleanup and documentation, but of course, it can be considered for Hacktoberfest. 🙂
@Panquesito7 Any point of contact who can review my PR ?
Hi, I'm not a maintainer, but could contribute. I agree with @Manupendra that the old sort implementations are in an imperative style. The the new implementations using a functional style are much more "Scala-like".
Besides a bit of typos in comments and formatting cleanup, both new algorithms look good to me.
Hi, I'm not a maintainer, but could contribute. I agree with @Manupendra that the old sort implementations are in an imperative style. The the new implementations using a functional style are much more "Scala-like". Besides a bit of typos in comments and formatting cleanup, both new algorithms look good to me.
Let me fix me that in my PR those typos and formats
Hi @Panquesito7 would you mind accepting this PR from @Manupendra?
Some clean up was done in the PR and as written earlier, the algorithms look fine and "Scala-like".
Hi @Panquesito7 would you mind accepting this PR from @Manupendra? Some clean up was done in the PR and as written earlier, the algorithms look fine and "Scala-like".
I don't know anything about Scala, but if you think it's fine, we can merge it. 🙂
We're looking for some maintainers in repositories such as this one.
Activity
Manupendra commentedon Oct 1, 2023
@Panquesito7 @andreicioban I just found exciting repo, I've suggested some enhancements and can be this be considered as a hacktoberfest contributions?
Panquesito7 commentedon Oct 4, 2023
Hey there! Of course! I do not know Scala or maintain this repository except for cleanup and documentation, but of course, it can be considered for Hacktoberfest. 🙂
Manupendra commentedon Oct 6, 2023
@Panquesito7 Any point of contact who can review my PR ?
carsten-langer commentedon Oct 7, 2023
Hi, I'm not a maintainer, but could contribute. I agree with @Manupendra that the old sort implementations are in an imperative style. The the new implementations using a functional style are much more "Scala-like".
Besides a bit of typos in comments and formatting cleanup, both new algorithms look good to me.
Manupendra commentedon Oct 8, 2023
Let me fix me that in my PR those typos and formats
carsten-langer commentedon Oct 27, 2023
Hi @Panquesito7 would you mind accepting this PR from @Manupendra?
Some clean up was done in the PR and as written earlier, the algorithms look fine and "Scala-like".
Panquesito7 commentedon Jan 15, 2024
I don't know anything about Scala, but if you think it's fine, we can merge it. 🙂
We're looking for some maintainers in repositories such as this one.