Skip to content

Instantly share code, notes, and snippets.

g++ `llvm-config --cxxflags` -c -o test.o test.cpp
In file included from /usr/include/c++/4.3/ext/hash_map:64,
from /usr/include/llvm/ADT/hash_map:37,
from /usr/include/llvm/Analysis/AliasSetTracker.h:23,
from /usr/include/llvm/LinkAllPasses.h:18,
from test.cpp:13:
/usr/include/c++/4.3/backward/backward_warning.h:33:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated.
g++ -o test `llvm-config --ldflags --libs` test.o
test.o: In function `__static_initialization_and_destruction_0':
/usr/include/llvm/Analysis/PostDominators.h:90: undefined reference to `llvm::PostDominanceFrontierLinkVar'
module Main where
import Control.Monad.Writer
import System(getArgs, getProgName)
data Column = LeftCol | MiddleCol | RightCol
instance Show Column where
show LeftCol = "left"
show MiddleCol = "middle"
show RightCol = "right"
module Main where
data Bst a = Nil | Node {
elt :: a,
l :: Bst a,
r :: Bst a} deriving Show
insert_ntr Nil x = Node x Nil Nil
insert_ntr n x | x < elt n = n {l = insert_ntr (l n) x}
| x > elt n = n {r = insert_ntr (r n) x}
module Main where
import System.Environment
import Control.Concurrent
import Control.Monad
process i inbox outbox = do
msg <- takeMVar inbox -- read message from inbox
when (i /= 0 || msg == 0) (putMVar outbox $! msg) -- all except the last node forward their message
when (msg /= 0) (process i inbox outbox) -- when not at the last message, recur.
fileCopyNoComment infile outfile = do
contents <- readFile infile
let out = map (fst . break (== '%')) $ lines contents
writeFile outfile $ unlines out
*4\r\n
$4\r\n
ZADD\r\n
$4\r\n
key1\r\n
$3\r\n
123\r\n
$6\r\n
query1\r\n
@nicolasff
nicolasff / gist:773056
Created January 10, 2011 17:04
Allowed elements in a set.
-module(test).
-export([allowed/1]).
% null case
allowed([]) ->
[];
% single element case
allowed([E]) ->
[[E]];
[
{
"disabled": ["*"]
},
{
"enabled": ["GET", "SET", "INCR"]
}
]
@nicolasff
nicolasff / grp.hs
Created April 13, 2011 17:48
Grouping numbers together in Haskell
-- Group blocks together.
import Data.List (intersperse)
grp :: [Int] -> [(Int,Int)]
grp [] = []
grp (x:xs) = pair x x xs where
pair lo hi (x:xs) | x == hi + 1 = pair lo x xs
pair lo hi xs | otherwise = (lo,hi): grp xs
time_in_sec total_inserted inserts_per_sec
0 0 0
1 170000 170000
2 330000 160000
3 440000 110000
4 590000 150000
5 730000 140000
6 870000 140000
7 1010000 140000
8 1150000 140000