by

Where communities thrive


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

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

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

    Example
    (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]) = {
        @tailrec
        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))
    
      partitionAndSort(list)
    }
    Vladimir Kostyukov
    @vkostyukov
    @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.
    Alykoff
    @Alykoff
    @vkostyukov Ok, I will do PR.
    Sayat
    @satybald
    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
    @vkostyukov
    It stands for Okasaki's book Purely Functional Datastructures.
    Sayat
    @satybald
    Got it! Thanks @vkostyukov for the answers ;)
    Ben Fradet
    @BenFradet
    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
    @BenFradet
    Artsiom Miklushou
    @mikla
    Hello.
    Do you have plans to cover all these data structures that you implemented by tests?
    Also, thank you for the project!
    afz
    @aamir-f
    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))