This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import cats.effect.{IO, Timer} | |
| import fs2.{Pull, Stream} | |
| import org.http4s._ | |
| import org.http4s.ServerSentEvent.EventId | |
| import org.http4s.client.Client | |
| import org.http4s.headers.{`Cache-Control`, Accept} | |
| import scala.concurrent.duration._ | |
| import SseClient._ | |
| final class SseClient private ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import io.circe.{Decoder, Encoder} | |
| import io.circe.syntax._ | |
| sealed trait JType | |
| /* | |
| etype = "number" | "object" | "integer" | "string" | "null" | "array" | |
| jtype = etype | array[etype] | |
| see: https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.1.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Scala 14 hrs 14 mins ███████████████▊░░░░░ 75.3% | |
| YAML 2 hrs 46 mins ███░░░░░░░░░░░░░░░░░░ 14.7% | |
| sbt 51 mins ▉░░░░░░░░░░░░░░░░░░░░ 4.6% | |
| textmate 23 mins ▍░░░░░░░░░░░░░░░░░░░░ 2.1% | |
| SQL 14 mins ▎░░░░░░░░░░░░░░░░░░░░ 1.3% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package forcomp | |
| import scala.collection.mutable | |
| object Anagrams { | |
| /** A word is simply a `String`. */ | |
| type Word = String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package patmat | |
| import common._ | |
| /** | |
| * Assignment 4: Huffman coding | |
| * | |
| */ | |
| object Huffman { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package objsets | |
| import TweetReader._ | |
| /** | |
| * A class to represent tweets. | |
| */ | |
| class Tweet(val user: String, val text: String, val retweets: Int) { | |
| override def toString: String = | |
| "User: " + user + "\n" + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package funsets | |
| /** | |
| * 2. Purely Functional Sets. | |
| */ | |
| object FunSets { | |
| /** | |
| * We represent a set by its characteristic function, i.e. | |
| * its `contains` predicate. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package recfun | |
| 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() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def binarySearchFunctional(list: Array[Int], target: Int): Int = { | |
| def bsf(list: Array[Int], target: Int, start: Int, end: Int): Int = { | |
| if (start>end) return -1 | |
| val mid = start + (end-start+1)/2 | |
| list match { | |
| case (arr:Array[Int]) if (arr(mid)==target) => mid | |
| case (arr:Array[Int]) if (arr(mid)>target) => bsf(list, target, start, mid-1) | |
| case (arr:Array[Int]) if (arr(mid)<target) => bsf(list, target, mid+1, end) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val filesHere = (new java.io.File(args(0))).listFiles | |
| def fileLines(file: java.io.File) = | |
| scala.io.Source.fromFile(file).getLines().toList | |
| def grep(pattern: String) = | |
| for ( | |
| file <- filesHere | |
| if file.getName.endsWith(".scala"); | |
| line <- fileLines(file) | |
| if line.trim.matches(pattern) | |
| ) println(file + ": " + line.trim) |
NewerOlder