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 My.Blogs | |
open System | |
open System.Collections.Generic | |
open System.Web | |
open IntelliFactory.WebSharper.Sitelets | |
type Id = int | |
type Html = string |
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
#lang racket | |
(define (quadratic a b c) | |
(let* ([det (- (* b b) (* 4 a c))] | |
[x1 (/ (- (sqrt det) b) (* 2 a))] | |
[x2 (/ (- (- (sqrt det)) b) (* 2 a))]) | |
(vector x1 x2))) |
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
type Regex<'T> = | |
| Choose of Regex<'T> * Regex<'T> | |
| Concat of Regex<'T> * Regex<'T> | |
| Empty | |
| Filter of ('T -> bool) | |
| Star of Regex<'T> |
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 NFA = | |
type State<'T> = | |
| Match | |
| Branch of State<'T> * State<'T> | |
| Read of ('T -> bool) * State<'T> | |
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 NFA = | |
[<CustomEquality>] | |
[<CustomComparison>] | |
type State<'T> = | |
| Match | |
| Branch of Pair<'T> | |
| Read of int * ('T -> bool) * State<'T> | |
member this.Key = |
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 NFA = | |
let Compile regex = | |
let k = ref 0 | |
let next () = | |
incr k | |
!k | |
let rec compile regex matched = | |
match regex with | |
| Choose (a, b) -> |
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 DFA = | |
open System.Collections.Generic | |
type State<'T> = | |
{ | |
IsMatch : bool | |
States : Set<NFA.State<'T>> | |
Transitions : Dictionary<'T,State<'T>> | |
} |
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 DFA = | |
let rec nextState current token = | |
match current.Transitions.TryGetValue token with | |
| true, state -> state | |
| _ -> | |
let rec loop current next = | |
if Set.isEmpty current then getState next else | |
let min = Set.minElement current | |
let current = Set.remove min current |
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
class Functor f where | |
fmap :: (a -> b) -> f a -> f b | |
instance Functor [] where | |
fmap = map |
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
type Box<'T1,'T2> = { Value : obj } | |
module List = | |
let Box (list: list<'T>) : Box<list<obj>,'T> = { Value = list } | |
let Unbox (x: Box<list<obj>,'T>) : list<'T> = x.Value :?> _ | |
type IFunctor<'T> = | |
abstract member Map : ('T1 -> 'T2) -> Box<'T,'T1> -> Box<'T,'T2> | |
let ListFunctor = |