Last active
January 1, 2020 15:01
-
-
Save pharpend/e5a311518f613d5dc94bbeb75071eb54 to your computer and use it in GitHub Desktop.
ghci.conf january 2020
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.Complex | |
import Text.Printf | |
import Test.QuickCheck | |
import Text.RE.PCRE | |
:set -XFlexibleContexts | |
:set -XOverloadedStrings | |
:set -XQuasiQuotes | |
:set -XScopedTypeVariables | |
let f2c dc = (dc - 32) * (5 / 9) | |
let c2f df = ((9 / 5) * df) + 32 | |
let lb = logBase 2 | |
let mu xs = (1 / fromIntegral (length xs)) * sum xs | |
let winpct w l = w / (w + l) | |
let gamesAbove500 w l = 0.5 * (w - l) | |
let gaf = gamesAbove500 | |
let gof = gamesAbove500 | |
let gamesOver500 = gamesAbove500 | |
let quotesum str = sum $ fmap (read :: String -> Int) $ words str | |
let qsum=quotesum | |
let fastForward = "x = offset/(rate - 1)" | |
let geomSum n r = ((1 + r) / r)*(1 - (1 / ((1 + r) ** (n + 1)))) | |
let geomSumM1 n r = geomSum n r - 1 | |
let geomSum' = geomSumM1 | |
let era er ip = (9 * er) / ip | |
let entropy = sum . fmap (\p -> (-1) * p * lb p) | |
let relEntropy ps qs = sum $ zipWith (\p q -> p*lb (p/q)) ps qs | |
-- stolen from https://rosettacode.org/wiki/Evaluate_binomial_coefficients#Haskell | |
let binom n k = foldl (\z i -> (z * ((n - i) + 1)) `div` i) 1 [1..k] | |
let diceprobs numUnknown mult = product [(5.0/6)**(numUnknown - m) | m <- [1..mult]] | |
-- :set prompt "λ >> " | |
:set prompt "ghci >> " | |
:set +t | |
:def hoogle \x -> return $ ":!hoogle \"" ++ x ++ "\"" | |
:def hoo \x -> return $ ":!hoogle \"" ++ x ++ "\"" | |
:def doc \x -> return $ ":!hoogle --info \"" ++ x ++ "\"" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment