Skip to content

Instantly share code, notes, and snippets.

View sleepynate's full-sized avatar

Nathan Dotz sleepynate

View GitHub Profile
@sleepynate
sleepynate / AnimalDemo.java
Created February 9, 2018 23:11 — forked from rtoal/AnimalDemo.java
An example of inheritance and polymorphism in Java
abstract class Animal {
private String name;
public Animal(String name) {
this.name = name;
}
public String speak() {
return name + " says " + sound();
}
public abstract String sound();
}
@sleepynate
sleepynate / Main.scala
Created February 18, 2016 14:03 — forked from anonymous/Main.scala
Scala.js Bouncing Taco
import Math._
object ScalaJSExample extends js.JSApp{
class HTMLImageElement extends dom.raw.HTMLImageElement {
var onload: js.Function1[dom.Event, _] = ???
}
def newUnit() = 2 * Math.random
def newMutPlus() = {
module PrimeFactors (primeFactors) where
primeFactors :: Integer -> [Integer]
primeFactors 1 = []
primeFactors x = primeFactors' x 2
where primeFactors' x n
| x < n = []
| x `mod` n == 0 && x > n = [n] ++ primeFactors' (x `div` n, n + 1)
| otherwise = [x]