I hereby claim:
- I am lfairy on github.
- I am lfairy (https://keybase.io/lfairy) on keybase.
- I have a public key whose fingerprint is 0658 29A6 73B2 9A01 6E68 EC42 4AFA FC07 E9D2 794C
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| -- | Find the triangle number T(n) | |
| triangle :: Integer -> Integer | |
| triangle n = (n * (1 + n)) `div` 2 | |
| -- | Find the greatest k where T(k) <= n | |
| invTriangle :: Integer -> Integer | |
| invTriangle n = (intSqrt (1 + 8*n) - 1) `div` 2 | |
| -- | Find the greatest k where k^2 <= n | |
| intSqrt :: Integer -> Integer |
| from collections import namedtuple | |
| class Transform(namedtuple('Transform', 'p q')): | |
| """ | |
| The value ``Transform(p, q)`` represents the matrix | |
| ``[[p+q, q], [q, p]]``. | |
| """ | |
| def __mul__(self, other): | |
| """Compose two transformations end-to-end.""" |
| use std::iter::Peekable; | |
| trait IteratorDedup: Iterator + Sized { | |
| fn dedup(self) -> Dedup<Self> where Self::Item: PartialEq { | |
| Dedup { | |
| inner: self.peekable(), | |
| emit: true, | |
| } | |
| } | |
| } |
Before:
running 4 tests
test empty_str_to_string ... bench: 32 ns/iter (+/- 3)
test i32_to_string ... bench: 81 ns/iter (+/- 1)
test long_str_to_string ... bench: 93 ns/iter (+/- 1)
test short_str_to_string ... bench: 75 ns/iter (+/- 0)
test result: ok. 0 passed; 0 failed; 0 ignored; 4 measured
| #!/bin/sh | |
| set -e | |
| USAGE='' | |
| SUBDIRECTORY_OK=1 | |
| . "$(git --exec-path)/git-sh-setup" | |
| if [ $# -gt 0 ] |
| -- Module is a Category and Profunctor and Monoid | |
| data Module a b | |
| ~ (b -> IO ()) -> Codensity IO (a -> IO ()) | |
| -- Action is a Functor and Monad | |
| data Action b r | |
| ~ ReaderT (b -> IO ()) IO r | |
| ~ (b -> IO ()) -> IO r | |
| connect :: String -> Int -> Module Message [Command] -> IO a |
| gst-launch-1.0 filesrc location=music.wav ! decodebin ! audioconvert ! vorbisenc ! oggmux ! filesink location=music.ogg |
| {-# LANGUAGE TypeFamilies #-} | |
| import Control.Applicative | |
| import Data.Functor.Compose | |
| ------------------------------------------------------------------------ | |
| -- Preliminaries | |
| (-->) :: Bool -> Bool -> Bool |
| traverse :: (FoldCase s1, FoldCase s2, Functor f) => (s1 -> f s2) -> CI s1 -> f (CI s2) | |
| traverse f = fmap CI.mk . f . CI.original | |
| cotraverse :: (FoldCase s1, FoldCase s2, Functor f) => (f s1 -> s2) -> f (CI s1) -> CI s2 | |
| cotraverse f = CI.mk . f . fmap CI.original | |
| -- Examples | |
| concat :: [CI ByteString] -> CI ByteString | |
| concat = cotraverse B.concat |