Given an arbitrary program:
@main def lcm(a: Int, b: Int): Int =
if(a < b) (a * (b / gcd(b, a))
else (b * (a / gcd(a, b))
def gcd(a: Int, b: Int): Int =
if(b == 0) a
// Author: Aly Cerruti | |
// Please follow along in Scastie, so you can see the output of statements: | |
// https://scastie.scala-lang.org/CLmK5tLuRd6rxXuEnba0rQ | |
// A Category | |
trait Category[ | |
// A collection of objects | |
Obj <: AnyKind, | |
// A constraint on those objects (Scala lacks dependent typing, so i.e. `Val = [A] =>> Monoid[A]` makes the category of Monoids) | |
Val[_ <: Obj], |
BITS 64 | |
org 0x00010000 | |
ehdr: | |
db 0x7F, "ELF" | |
db 2 ; 64 bits | |
db 1 ; LE | |
db 1 ; ELF v1 | |
db 0 ; SysV |
???? ???? ???? 0000: | |
[TODO: document special cases related to Xemnas] | |
???? ???? ??0? 0000: | |
???? ???? ??00 0000 iiii iiii iiii iiii iiii iiii iiii iiii: | |
load immediate INT | |
push to TP | |
???? ???? ??01 0000 ffff ffff ffff ffff ffff ffff ffff ffff: | |
load immediate FLOAT | |
push to TP | |
iiii iiii ii1m 0000 oooo oooo oooo oooo: |
// show Fluffy instances | |
trait Fluffy[F[_]] { | |
def furry[A, B](fa: F[A])(f: A => B): F[B] | |
} | |
// Exercise 1 | |
// Relative Difficulty: 1 | |
implicit def fluffyList: Fluffy[List] = new Fluffy[List] {} | |
// Exercise 2 |
beep -D 3 -n -f 293 -l 139 -D 0 -n -f 293 -l 113 -D 7 -n -f 587 -l 97 -D 150 -n -f 440 -l 142 -D 225 -n -f 415 -l 120 -D 136 -n -f 391 -l 91 -D 150 -n -f 349 -l 243 -D 7 -n -f 293 -l 113 -D 7 -n -f 349 -l 113 -D 7 -n -f 391 -l 118 -D 9 -n -f 261 -l 142 -D 0 -n -f 261 -l 113 -D 7 -n -f 587 -l 97 -D 150 -n -f 440 -l 142 -D 225 -n -f 415 -l 120 -D 136 -n -f 391 -l 91 -D 150 -n -f 349 -l 243 -D 7 -n -f 293 -l 113 -D 7 -n -f 349 -l 113 -D 7 -n -f 391 -l 118 -D 9 -n -f 246 -l 142 -D 0 -n -f 246 -l 113 -D 7 -n -f 587 -l 97 -D 150 -n -f 440 -l 142 -D 225 -n -f 415 -l 120 -D 136 -n -f 391 -l 91 -D 150 -n -f 349 -l 243 -D 7 -n -f 293 -l 113 -D 7 -n -f 349 -l 113 -D 7 -n -f 391 -l 118 -D 9 -n -f 233 -l 142 -D 0 -n -f 233 -l 113 -D 7 -n -f 587 -l 97 -D 150 -n -f 440 -l 142 -D 225 -n -f 415 -l 120 -D 136 -n -f 391 -l 91 -D 150 -n -f 349 -l 243 -D 7 -n -f 293 -l 113 -D 7 -n -f 349 -l 113 -D 7 -n -f 391 -l 118 -D 9 -n -f 146 -l 20 -D 0 -n -f 293 -l 20 -n -f 146 -l 20 -D 0 -n -f 293 -l 20 -D 0 -n -f 293 -l 28 -D 0 -n -f 293 |
import cats._, cats.data._, cats.syntax.all._ | |
import scala.annotation.tailrec | |
object Main2 { | |
sealed trait Trace { | |
def show: String | |
} | |
object Trace { | |
implicit val showTrace: Show[Trace] = Show.show(_.show) |
import cats._, cats.data._, cats.syntax.all._ | |
import scala.annotation.tailrec | |
object Main { | |
case class Snapshot(comparisons: Int, exchanges: Int, tikz: String) | |
def main(args: Array[String]): Unit = { | |
val vector: Vector[Int] = Vector(55, 50, 10, 40, 80, 90, 60, 100, 70, 80, 20, 50, 22) | |
val (snapshots, _, ()) = heapify[Int].runEmpty(vector).value |