View gist:7f6d4ce58edbceec5f16
1 2 3 4 5 6 7 8 9
#!/usr/bin/python
 
import ninja_syntax
import itertools
import os
import fnmatch
import re
import sys
import argparse
View filetoobig.md

The asymmetries of C++

This is lighthearted collection of asymmetries of the C++ language. This is not, in any way, intended as a critic.


Partial specialization is allowed for class templates but not for function templates

§14.5.5 [temp.class.spec] describes the semantic and syntax for class template partial specialization such as, given:

View equal100.hs
1 2 3 4 5 6 7 8 9 10
-- 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]]
View Vec.elm
1 2 3 4 5 6 7 8 9 10
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
View a8.cpp
1 2 3 4 5 6 7 8 9 10
#include <iostream>
#include <fstream>
#include <map>
#include <stdexcept>
#include <vector>
 
namespace a8 {
 
// aliases
using word = std::string;
View ngrams.hs
1 2 3 4 5 6 7 8 9 10
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 ()
View gist:ae0ae922199468e43f4c
1 2 3 4 5 6 7 8 9 10
module Snok.Engine
( Initializable(..)
, Drawable(..)
, play ) where
 
import qualified Graphics.UI.GLFW as GLFW
import System.Exit (exitSuccess, exitFailure)
import System.IO (stderr, hPutStrLn, hFlush)
import Control.Monad (when, unless)
import Control.Concurrent.STM
View gist:d43507abfb86622c79a2
1 2 3 4 5 6 7 8 9 10
{-| Class that represents an object that can be updated
every x amount of time (where x is fixed). |-}
class Mutable t where
update :: t -> Engine t
updateRate :: UPS
 
{-| Class representing an object that changes when
an user performs input operations. |-}
class Reactive t where
react :: Input -> t -> Engine t
View model.pm
1 2 3 4 5 6 7 8 9 10
use strict;
use warnings;
use XML::LibXML;
 
package Model {
 
# Factory class method that
# builds a model from an XML node.
sub _from_node {
my $class = shift;
View rest.hs
1 2 3 4 5 6 7 8 9 10
{-# LANGUAGE TypeFamilies, FlexibleInstances #-}
 
module Main where
 
-- API
class Referenceable a where
type ReferenceType a :: *
expand :: ReferenceType a -> IO a
 
-- Post & posts example
Something went wrong with that request. Please try again.