Skip to content

Instantly share code, notes, and snippets.

View BeachBird's full-sized avatar

Natalina BeachBird

View GitHub Profile
@BeachBird
BeachBird / Anagrams.scala
Last active March 10, 2022 17:01
Functional Programming Principles in Scala. 5. Anagrams
package forcomp
import common._
object Anagrams {
/** A word is simply a `String`. */
type Word = String
/** A sentence is a `List` of words. */
@BeachBird
BeachBird / Huffman.scala
Created April 27, 2015 17:41
Functional Programming Principles in Scala. 4. Huffman Coding.
package patmat
import common._
/**
* Assignment 4: Huffman coding
*
*/
object Huffman {
@BeachBird
BeachBird / TweetSet.scala
Created April 25, 2015 15:13
Functional Programming Principles in Scala. Object-Oriented Sets 3.1 Filtering 3.2 Taking Unions 3.3 Sorting Tweets by Their Influence 3.4 Tying everything together
package objsets
import common._
import TweetReader._
import java.lang.String._
/**
* A class to represent tweets.
*/
class Tweet(val user: String, val text: String, val retweets: Int) {
@BeachBird
BeachBird / QuickCheck.scala
Created April 24, 2015 16:33
Principles of Reactive Programming. Quickcheck.
package quickcheck
import common._
import org.scalacheck._
import Arbitrary._
import Gen._
import Prop._
abstract class QuickCheckHeap extends Properties("Heap") with IntHeap {
@BeachBird
BeachBird / FunSetSuite.scala
Created April 24, 2015 16:27
Functional Programming Principles in Scala. Functional Sets. 2.1 Basic Functions on Sets 2.2 Queries and Transformations on Sets
package funsets
import org.scalatest.FunSuite
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
/**
* This class is a test suite for the methods in object FunSets. To run
* the test suite, you can either:
@BeachBird
BeachBird / Main.scala
Last active August 17, 2016 11:23
Functional Programming Principles in Scala. Recfun. Exercise 1: Pascal’s Triangle Exercise 2: Parentheses Balancing Exercise 3: Counting Change
package recfun
import common._
object Main {
def main(args: Array[String]) {
println("Pascal's Triangle")
for (row <- 0 to 10) {
for (col <- 0 to row)
print(pascal(col, row) + " ")
println()