$ brew install ghc
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/ghc-7.4.2.m
######################################################################## 100.0%
==> Pouring ghc-7.4.2.mountainlion.bottle.tar.gz
==> Caveats
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> import maze._ | |
import maze._ | |
scala> val m = Mazes.load(new java.io.File("maze.txt")) | |
m: maze.Maze = maze.Maze@20ccb51 | |
scala> Mazes.encodeRunLength(m.solve.get) | |
res0: List[(maze.Direction.Value, Int)] = List((S,1), (E,10), (S,2), (W,31), (N,4), (E,2), (S,2), (E,2), (N,4), (E,7), (N,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
import java.awt.image.{BufferedImage => BI} | |
import java.io.File | |
import javax.imageio.ImageIO | |
object avhash extends App { | |
val (w, h) = (16, 16) | |
def toHash(originFile: File) = { | |
def toGray(originFile: File) = { | |
val newImage = new BI(w, h, BI.TYPE_BYTE_GRAY) | |
val g = newImage.createGraphics() |
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
/tunes.txt |
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
#!/bin/sh | |
exec scala "$0" "$@" | |
!# | |
val helpMessage = """ | |
Usage: | |
-n do not output the trailing newline | |
-x repeat x times |