I hereby claim:
- I am shoooe on github.
- I am tpigarelli (https://keybase.io/tpigarelli) on keybase.
- I have a public key ASCbdD34wOQtajdGmowxTw6Vce6Ce5CKBsPf926SpZ0tMwo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
#include <iostream> | |
#include <memory> | |
#include <cassert> | |
enum class node_color { | |
red, | |
black | |
}; | |
template<typename DataType> |
In set theory we have that a domain is the set of all inputs for which a function is defined and the image is the set of possible outputs given those inputs. You would think this would be enough, but no: we also have the concept of codomain, which is the set of all possible outputs and some.
This also leads to the distinction between "surjective" functions and non-"surjective" functions (functions that have the image being equal to the codomain and those that don't, respectively). This distinction seems to provide no useful information about the function itself.
Now, let's make an example, we have:
ƒ : {a, b, c, d} -> {1, 2, 3, 4}
ƒ a = 1
namespace detail { | |
template<typename It> | |
It partition(It begin, It end) { | |
if (begin == end) return end; | |
auto pivot = *(end - 1); | |
auto left = begin; // left partion past the end | |
for (auto right = begin; right != end; ++right) { | |
if (*right <= pivot) { | |
std::iter_swap(left, right); |
This is lighthearted collection of asymmetries of the C++ language. This is not, in any way, intended as a critic.
§14.5.5 [temp.class.spec] describes the semantic and syntax for class template partial specialization such as, given:
-- Write a program that outputs all possibilities to put + or - or nothing | |
-- between the numbers 1, 2, ..., 9 (in this order) such that the result is | |
-- always 100. For example: 1 + 2 + 34 – 5 + 67 – 8 + 9 = 100. | |
import Control.Monad (replicateM) | |
ints :: [String] | |
ints = map (\i -> [i]) ['1'..'9'] | |
inbetweens :: [[String]] |
type alias Unit = Float | |
type Vec2 = Vec2 Unit Unit | |
(|+|) : Vec2 -> Vec2 -> Vec2 | |
(Vec2 ax ay) |+| (Vec2 bx by) = Vec2 (ax + bx) (ay + by) | |
negate : Vec2 -> Vec2 | |
negate (Vec2 x y) = Vec2 (-x) (-y) | |
(|-|) : Vec2 -> Vec2 -> Vec2 |
#include <iostream> | |
#include <fstream> | |
#include <map> | |
#include <stdexcept> | |
#include <vector> | |
namespace a8 { | |
// aliases | |
using word = std::string; |
groupEvery :: Int -> [a] -> [[a]] | |
groupEvery n lst | |
| length lst < n = [] | |
| otherwise = take n lst : groupEvery n (tail lst) | |
ngrams :: Int -> String -> [String] | |
ngrams n = concatMap (groupEvery n . fillWord '_') . words | |
where fillWord f w = f : (w ++ replicate (n - 1) f) | |
main :: IO () |
module Main where | |
import Prelude hiding (id) | |
import Data.List (intersperse) | |
import System.Random | |
import Control.Applicative | |
type PieceId = String | |
type PieceContent = Char | |