This file contains 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
let isPrime = function | |
| n when n < 2 -> false | |
| n -> [2 .. n-1] |> List.forall ((%) n >> (<>) 0) | |
[0..100] | |
|> List.map (fun x -> if isPrime x then "JOJO!" else string x) | |
|> List.iter (printfn "%s") |
This file contains 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 VendingMachine | |
type Yen = | |
| Thousand | |
| FiveHundred | |
| Hundred | |
| Fifty | |
| Ten |
This file contains 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 controllers | |
import org.specs2._ | |
import specification._ | |
import play.api.test._ | |
import play.api.test.Helpers._ | |
class ApplicationSpec extends Specification with AroundExample { def is = |
This file contains 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 parser; | |
import util.parsing.combinator.JavaTokenParsers | |
import java.math.MathContext | |
case class Sum(init:Expression, max:Expression, expr:Expression) extends Expression | |
case class Value(digit:BigDecimal) extends Expression | |
case class Variable() extends Expression | |
case class Add(left:Expression, right:Expression) extends Expression | |
case class Sub(left:Expression, right:Expression) extends Expression |
This file contains 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 ast; | |
import visitor.ExpressionVisitor; | |
public final class BinaryExpression implements Expression { | |
public final Expression left; | |
public final Op operator; | |
public final Expression right; | |
This file contains 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
grammar Calculator; | |
options { | |
output = AST; | |
ASTLabelType=CommonTree; | |
} | |
tokens { SUM; NEG; VARIABLE; } | |
@members { CommonTree subExpr; } |
NewerOlder