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
abstract class Animal { | |
private String name; | |
public Animal(String name) { | |
this.name = name; | |
} | |
public String speak() { | |
return name + " says " + sound(); | |
} | |
public abstract String sound(); | |
} |
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 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() = { |
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
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] |