The Fake Geek's blog: Scala note 4: Huffman Coding
Scala note 4: Huffman Coding This post is based on Coursera's Scala course homework for week 4 and week 5. The whole problem can be found here . Some notes: Case classes : they are regular classes which export their constructor parameters and which provide a recursive decomposition mechanism via pattern matching. Pattern matching: allows to match on any sort of data with a first-match policy. List.groupBy : Partitions this traversable collection into a map of traversable collections according to some function. /: or folderLeft : applying a binary operator to a start value and all elements of this sequence, going left to right. z /: xs is the same as xs foldLeft z Map.getOrElse(default value): Returns the value associated with a key, or a default value if the key is not contained in the map. List.sortBy: sorts the sequence according to the Ordering which results from transforming an implicitly given Ordering with a transform function. List.flatMap:Read full article from The Fake Geek's blog: Scala note 4: Huffman Coding
No comments:
Post a Comment