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; } |
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
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 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
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
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
open FSharpx | |
let test () = | |
let rand = Random() | |
let list = Seq.init 20000 (fun _ -> rand.Next()) |> Seq.distinct |> Seq.toList | |
let d = 3 | |
let n = 1 | |
let t1 = DateTime.Now |
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
(* | |
Reference: http://en.wikipedia.org/wiki/Levenshtein_distance#Example | |
kitten → sitten (substitution of 's' for 'k') | |
sitten → sittin (substitution of 'i' for 'e') | |
sittin → sitting (insertion of 'g' at the end). | |
*) | |
open FSharpx.DataStructures | |
open FSharpx.ByteString |
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
namespace FSharpx | |
type Stream<'a> = | |
| Chunk of 'a | |
| Empty | |
| EOF | |
type Iteratee<'el,'a> = | |
| Done of 'a * Stream<'el> | |
| Error of exn | |
| Continue of (Stream<'el> -> Iteratee<'el,'a>) |
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
// NaturalSpec: https://github.com/forki/NaturalSpec | |
// unquote: http://code.google.com/p/unquote/ | |
open NaturalSpec.Utils | |
open NaturalSpec | |
open NUnit.Framework | |
open Swensen.Unquote | |
let check (assertType,a,b,value) = | |
let outputFail f message = |
OlderNewer