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
module FilterTree where | |
import Data.Maybe (mapMaybe) | |
data Tree a b = Leaf a | |
| Node a [Tree a b] | |
deriving Show | |
filterTree :: (a -> Bool) -> Tree a b -> Maybe (Tree a b) | |
filterTree p tree = |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Gists</title> | |
<link type="text/css" rel="stylesheet" href="style.css"> | |
<script type='text/javascript' src='lib/zepto.min.js'></script> | |
<script type='text/javascript' src='lib/knockout-2.3.0.js'></script> | |
<script type='text/javascript' src='lib/knockout.mapping-latest.js'></script> | |
</head> |
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
var events = ko.mapping.fromJS([]); | |
ko.applyBindings({ | |
events: events, | |
onRowClicked: function (row) { | |
// modify model to update UI. Will be re-updated by next ajax call :P | |
row.actor.login("FOO"); | |
} | |
}); |
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
{-# LANGUAGE QuasiQuotes #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
import Data.List (intercalate) | |
import Data.Maybe (fromMaybe) | |
import Network.HTTP.Conduit (simpleHttp) | |
import Control.Concurrent.Async (mapConcurrently) |
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
module Reco where | |
import Prelude hiding (product) | |
import qualified Data.Set as Set | |
import Data.Set(Set) | |
import qualified Data.Map as Map | |
import Data.Map(Map) | |
import Data.List(sortBy) | |
import Data.Ord (comparing) |
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
module Friends where | |
data Relation = Friend | Cousin | Professor deriving (Show, Eq) | |
data Person = Person String deriving (Show, Eq) | |
data Fact = Fact Relation (Person, Person) deriving (Show, Eq) | |
data Graph = Graph [Fact] deriving Show | |
areFriends :: Graph -> Person -> Person -> Bool | |
areFriends (Graph facts) person1 person2 = | |
(not . null) [(p1, p2) | Fact Friend (p1, p2) <- facts, p1 == person1 && p2 == person2] |
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
{-# LANGUAGE OverloadedStrings #-} | |
import qualified Data.ByteString.Lazy as LBS | |
import qualified Data.Text as Text | |
import Data.Text (Text) | |
import Data.Aeson (encode, decode, Value, Value(..)) | |
import qualified Data.HashMap.Strict as HashMap | |
import Data.Vector ((!)) | |
path :: Text -> Value -> Value |
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
var create = function (proto) { | |
var F = function () {}; | |
F.prototype = proto; | |
return new F(); | |
}; | |
var Point = {}; | |
Point.initialize = function (x, y) { | |
this.x = x; | |
this.y = y; |
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
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
import Control.Applicative | |
import Snap.Core | |
import Snap.Util.FileServe | |
import Snap.Http.Server | |
import Data.Monoid (mconcat) | |
import Blaze.ByteString.Builder.Char8 | |
import Blaze.ByteString.Builder |
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
let push : float list -> string -> float list = | |
fun stack input -> match stack, input with | |
| (b::a::rest), "+" -> a +. b::rest | |
| (b::a::rest), "-" -> a -. b::rest | |
| (b::a::rest), "*" -> a *. b::rest | |
| (b::a::rest), "/" -> a /. b::rest | |
| rest, number -> (float_of_string number)::rest | |
let polish_eval : string -> float = | |
fun input -> |