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
{-# LANGUAGE BangPatterns #-} | |
import Data.Array.IO | |
import Data.Array.Base | |
import Data.Bits | |
import Data.Int (Int32) | |
main = do | |
!inits <- return . map (fromIntegral . bin2signed) . lines =<< getContents | |
program <- newListArray (0,31) inits :: IO (IOUArray Int Int) | |
v <- ssem program |
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
00000000000000000000000000000000 | |
01000000000000000000000000011000 | |
01100000000000000000000000011010 | |
01000000000000000000000000011010 | |
01100000000000000000000000011011 | |
01000000000000000000000000010111 | |
10000000000000000000000000011011 | |
11000000000000000000000000000000 | |
00100000000000000000000000010100 | |
10000000000000000000000000011010 |
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
stack = [] | |
for line in sys.stdin: | |
dec = int('0b' + line, 2) | |
signed = struct.unpack('=l', struct.pack('=L', dec & 0xffffffff))[0] | |
stack.append(signed) |
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
{- | |
Place contents of this file in $HOME/.ghci then run | |
$ cabal install -j2 hoogle | |
$ hoogle data | |
-} | |
let ghciEscapeShellArg arg = "'" ++ concatMap (\c -> if c == '\'' then "'\"'\"'" else [c]) arg ++ "'" | |
:def! h return . (":! hoogle --color --count=20 " ++) . ghciEscapeShellArg |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
#include <ccan/list/list.h> | |
struct context { | |
struct list_head connections; | |
int num_connections; | |
}; |
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
#include <iostream> | |
#include <future> | |
#include <vector> | |
#include <algorithm> | |
#include <numeric> | |
#include <chrono> | |
template<typename Ran> | |
int parallel_sum(Ran b, Ran e) | |
{ |
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
#include <exception> | |
#include <future> | |
#include <thread> | |
#include <tbb/concurrent_queue.h> | |
namespace { | |
template<typename Future, typename F, typename T> | |
void set_value(std::promise<Future>& p, F& f, T& t) { | |
p.set_value(f(t)); | |
} |
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
class Comonad w where | |
(=>>) :: w a -> (w a -> b) -> w b | |
extract :: w a -> a | |
data T a = L a | B (T a) a (T a) deriving (Eq, Show) | |
unit :: a -> T a | |
unit = L | |
counit :: T a -> a |
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
#!/usr/bin/env bash | |
# $ gostart x | |
# vim x.go | |
FILENAME="$1" | |
cp "$GOROOT"/doc/Makefile . | |
sed -i '' -e "s/tmpltohtml/"$FILENAME"/g" -e 's/\.\./$\(GOROOT\)/' -e '/^#.*/d' Makefile | |
touch "$1".go |
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
@pattern(r'^([a-zA-Z_\$\%][a-zA-Z_0-9\{\}]*)\s*:(?<=:)(?::([a-zA-Z_\$][a-zA-Z_0-9\{\}]*)?:)?\s*(.*)$') | |
def target(match, env=env): | |
labels = ('name', 'dep', 'components') | |
groups = dict(zip(labels, match.groups())) | |
for k, v in groups.iteritems(): | |
groups[k] = env.interp(v) if v else v | |
name, dep = groups['name'], groups['dep'] | |
components = re.findall('\w+', groups['components']) | |
makefile.addtarget(name, dep, components) |