Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    Vladimir Kostyukov
    Feel free to ping me with any questions about Scalacaster or Purely Functional Data Structures in Scala.

    Hello! Sorry for my English.
    Firstly, thanks for scalacaster!

    I have a question.
    Why are you not using @scala.annotation.tailrec?

    (QuickSort.scala)[https://github.com/vkostyukov/scalacaster/blob/master/src/sort/QuickSort.scala] may be look like this:

    import scala.annotation.tailrec
    def quicksort[A <% Ordered[A]](list: List[A]): List[A] = {
      def sort(t: (List[A], A, List[A])): List[A] = t match {
        case (Nil, p, Nil) => List(p)
        case (l, p, g) =>  partitionAndSort(l) ::: (p :: partitionAndSort(g))
      def partition(as: List[A]): (List[A], A, List[A]) = {
        def loop(p: A, as: List[A], l: List[A], g: List[A]): (List[A], A, List[A]) = 
          as match {
            case h :: t => if (h < p) loop(p, t, h :: l, g) else loop(p, t, l, h :: g)
            case Nil => (l, p, g)
        loop(as.head, as.tail, Nil, Nil)
      def partitionAndSort(as: List[A]): List[A] = 
        if (as.isEmpty) Nil
        else sort(partition(as))
    Vladimir Kostyukov
    @Alykoff Hey! Yeah, I should've used this in the first place. Anyways, I'd love to see a PR that fills the missing gaps and puts the @tailrec annotations wherever possible.
    @vkostyukov Ok, I will do PR.
    Happy New Year!
    While looking at the source code of the Tree.scala, I found there's a mentions to some exercises from the book(?). Would you mind to specify what PFDS stands for?
    • Exercise 2.5a @ PFDS.
    Vladimir Kostyukov
    It stands for Okasaki's book Purely Functional Datastructures.
    Got it! Thanks @vkostyukov for the answers ;)
    Ben Fradet
    Hey @vkostyukov, great project
    I was running through some of the examples, particularly the sorting algorithms
    And I was wondering if we shouldn't replace the view bounds by implicit parameters since view bounds are now deprecated
    What do you think?
    Ben Fradet
    Artsiom Miklushou
    Do you have plans to cover all these data structures that you implemented by tests?
    Also, thank you for the project!
    Hi all
    This message was deleted
    @vkostyukov , regarding contains method inside Tree.scala, looks like it needs some change.
    else if (x < t.value) loop(t.left, c)
    should be replaced by
    else if (x < t.value) loop(t.left, Some(t.value))
    Vladimir Kostyukov
    @aamir-f want to send a PR with a fix?
    Vasile Gorcinschi
    Hello @vkostyukov! Based on this README part can we conclude that you would prefer to not publish your project to maven central? :-)