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 Window | |
( Window | |
-- | Monoidal windows | |
, empty | |
, update | |
, shift | |
-- | Non-monoidal windows | |
, replicate |
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 Demo where | |
import Control.Applicative | |
import Control.Monad.ST | |
import UnionFind | |
import Weight | |
-- | Return the class label if the class is represented by a constructed type | |
con_ :: Class s (Weight a) b -> ST s (Maybe b) | |
con_ c = ((== Con) . tag <$> weight c) >>= if_ |
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 Linear | |
where | |
import Prelude hiding (error) | |
import Control.Arrow | |
import Data.List | |
import Data.Vector (Vector) | |
import qualified Data.Vector as V | |
-- | Independent variables from a single observation |
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 ScopedTypeVariables #-} | |
module KMeans | |
( euclidean | |
, kMeans | |
, kMeansPar | |
, chunk | |
, random | |
) where |
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
import Data.Ord | |
import Data.List | |
import Test.QuickCheck | |
-- | Quantify how "unsorted" a given list of elements is, by computing | |
-- at each position in the list: how many later elements are smaller? | |
-- | |
-- e.g. cost "abc" == 0 | |
-- cost "acb" == 1 | |
-- cost "cba" == 2 |
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
(function() { | |
var otherLib = (typeof($) == 'function'); | |
if (typeof(jQuery) != 'undefined') { | |
alert('jQuery already defined'); | |
return; | |
} | |
function getScript(url, callback) { | |
var script = document.createElement('script'); |
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
#!/usr/bin/perl | |
use URI::Escape; | |
my $url = 'http://careers.stackoverflow.com/jobs/feed?searchTerm='; | |
# Either use search terms given as command-line arguments, or use default terms | |
my $q = join('+', map { uri_escape($_); } (@ARGV > 0) ? | |
@ARGV : ('-.net', '-css', '-c#', '-android', '-php', '-ios', '-vb.net', '-excel' )); | |
# Read XML from child process |
The example below creates a refinement module which adds a method to instances of Integer
. In the Test
class, we bring it into scope by declaring using Refinements
. Next, we create an instance method using def_delegators
named Test#xxx
that calls @k.xxx
, which should resolve to the refinement method we added to Integer
. Finally, we "manually" create essentially the same method, this time named yyy
, but we define it "manually" without using def_delegators
.
require "forwardable"
module Refinements
refine Integer do
def xxx
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
-- Covariate functor | |
class Fun f where | |
fun :: (a -> b) -> f a -> f b | |
-- Contravariate functor | |
class Con f where | |
con :: (b -> a) -> f a -> f b | |
-- Function parameterized over input type 'i' |