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
import Data.List | |
import Text.Regex.Posix | |
rule :: Int -> String -> ((String, String, String, [String]) -> String) -> ([Int],String) -> ([Int],String) | |
rule x pat f (routes,s) = | |
let | |
res = s =~~ pat :: Maybe (String, String, String, [String]) | |
in case res of | |
Just r -> (x:routes, f r) | |
Nothing -> (routes,[]) |
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
import qualified Data.ByteString.Char8 as BS | |
import qualified Data.Vector as V | |
import qualified Data.List as L | |
import qualified Data.Heap as H | |
import qualified Data.IntSet as S | |
type Node = Int | |
type Cost = Int | |
data Edge = Edge Node Cost deriving (Eq, Show) | |
type Edges = [Edge] |
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
-- where the target number k of clusters is set to 4. | |
-- What is the maximum spacing of a 4-clustering? | |
import qualified Data.ByteString.Char8 as BS | |
import Control.Monad | |
import Control.Monad.ST | |
import qualified Data.Heap as H | |
import System.Environment | |
import Data.Array.MArray | |
import Data.Array.ST |
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
<!doctype html> | |
<html> | |
<head> | |
<title>AF Mobile polymer</title> | |
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes"> | |
<script src="./bower_components/platform/platform.js"></script> |
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
%% Provide with a Goal and it will iterate towards it. | |
guess(Goal, Res) :- | |
guessIterate(Goal, [], Res). | |
guessIterate(Goal, Guesses, Res) :- | |
makeGuess(Guess), | |
check_against_guesses(Guess, Guesses), | |
score(Guess, Goal, ThisScore), | |
( |
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
import qualified Data.ByteString.Char8 as BS | |
import Control.Monad | |
import Control.Monad.ST | |
import Data.Array.ST | |
import Data.Array | |
qsort :: (STArray s Int Int) -> Int -> Int -> ST s () | |
qsort arr min mx = | |
if mx - min < 1 then |
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
import qualified Data.ByteString.Char8 as BS | |
import qualified Data.Vector as V | |
import qualified Data.List as L | |
import qualified Data.IntSet as IS | |
import qualified Data.PSQueue as PSQ | |
type NodeName = Int | |
type Dist = Int | |
type Edge = (NodeName, Dist) | |
type Edges = [Edge] |
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
"use strict" | |
/* | |
An implementation of the Maybe monad in ES6, representing | |
- Maybe as a singleton array | |
- Nothing and null | |
Compiled and run with Traceur | |
traceur --out build.js --script maybe.js |
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
import Control.Applicative | |
import Control.Monad | |
-- :k MonadClass :: * -> * | |
data MonadClass a = MonadClass a | |
-- fmap :: (a -> b) -> (m a -> m b) | |
instance Functor MonadClass where | |
fmap f = (<*>) (MonadClass f) |
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
import Http | |
import Markdown | |
import Html exposing (Html, div, text) | |
import Task exposing (Task, andThen) | |
import Json.Decode as Json exposing (..) | |
type alias ValWithErr = Result String Int | |
main : Signal Html | |
main = |
OlderNewer