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 Main where | |
import Data.List (intercalate) | |
import Control.Applicative((<$>)) | |
import Control.Monad(forM) | |
import System.Environment(getArgs) | |
import System.IO (withFile, hGetLine, IOMode(ReadMode)) | |
newtype Edge = Edge (Int, Int) | |
deriving Show |
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
INFO [2014-03-21 17:38:19Z]: Starting MonoDevelop 4.2.3 | |
INFO [2014-03-21 17:38:19Z]: Running on Mono 3.0.6 (tarball Sat Sep 28 04:42:52 UTC 2013) (64-bit) | |
INFO [2014-03-21 17:38:19Z]: Using GTK+ 2.24.22 | |
INFO [2014-03-21 17:38:20Z]: Add-in loaded: MonoDevelop.Core | |
INFO [2014-03-21 17:38:20Z]: Add-in loaded: MonoDevelop.Ide | |
WARNING [2014-03-21 17:38:20Z]: No proxy credential provider was found | |
INFO [2014-03-21 17:38:20Z]: Initializing Runtime Mono 3.0.6 | |
INFO [2014-03-21 17:38:20Z]: Add-in loaded: MonoDevelop.Debugger | |
INFO [2014-03-21 17:38:20Z]: Add-in loaded: MonoDevelop.SourceEditor2 | |
INFO [2014-03-21 17:38:20Z]: Add-in loaded: MonoDevelop.VersionControl |
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
{-# LANGUAGE BangPatterns #-} | |
piCalc :: Int -> Float | |
piCalc iterations = step * loop 0 iterations | |
where step = 1.0 / fromIntegral iterations | |
loop a i = | |
if i == 0 then a | |
else | |
let x = (fromIntegral i - 0.5) * step | |
!a' = a + (4.0 / (1.0 + x*x)) |
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
### Keybase proof | |
I hereby claim: | |
* I am carstenkoenig on github. | |
* I am carstenkoenig (https://keybase.io/carstenkoenig) on keybase. | |
* I have a public key whose fingerprint is BB93 DA5D BF8A 3E50 2EF7 F595 E68E DE6B D673 43C5 | |
To claim this, I am signing this object: |
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 seqInnerJoin predicate seq1 seq2 = | |
let findPairs predicate seq2 element1 = | |
seq2 | |
|> Seq.where (predicate element1) | |
|> Seq.map (fun element2 -> element1, element2) | |
seq1 | |
|> Seq.map (findPairs predicate seq2) | |
|> Seq.collect (fun pair -> pair) | |
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
// Die Frage war, warum | |
["1", "5"].map(parseInt); | |
// schief geht. | |
// Johannes hatte die Antwort, die ich nicht vertanden habe | |
// die Konsole hilft weiter: | |
var f = function() { console.log(arguments); } | |
["1", "5"].map(f) | |
> ["1", 0, Array[2]] |
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 Vigenere where | |
import Data.Char | |
import Test.QuickCheck.Test (quickCheck) | |
encrypt :: String -> String -> String | |
encrypt key = zipWith (shiftChar (+)) (cycle key) | |
decrypt :: String -> String -> String | |
decrypt key = zipWith (shiftChar (flip (-))) (cycle 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
import Data.Maybe (fromJust) | |
import Data.List (sort) | |
rankList :: [Int] -> [Int] | |
rankList ns = map (fromJust . (flip lookup) ranks) ns | |
where ranks = zipWith (flip (,)) [1..] . sort $ ns |
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
{-# LANGUAGE BangPatterns #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
import GHC.Exts (sortWith) | |
import Data.Function (on) | |
import Data.List (maximumBy, sortBy, nub, foldl') | |
import qualified Data.Map.Strict as M |
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 EventSourcing | |
module View = | |
/// the View's builder-type - includes bookkepping for intermediate types and should be hidden | |
/// from (poor) users view | |
type T<'e,'i,'a> = private { foldF : 'i -> 'e -> 'i; project : 'i -> 'a; init : 'i } | |
/// creates a view, based on a fold over intermediate values and a final projection | |
let createWithProjection (p : 'i -> 'a) (i : 'i) (f : 'i -> 'e -> 'i) = |
OlderNewer