This file contains hidden or 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
import numpy as np | |
import re | |
NUMBER = re.compile(r'[0-9]+(\.[0-9]+)?') | |
def tokenize(s): | |
orig_str = s | |
while len(s) > 0: | |
m = NUMBER.match(s) | |
if m: |
This file contains hidden or 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 LambdaCase #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
import Control.Monad | |
import Control.Monad.Trans.Class | |
import Control.Monad.Trans.Except | |
import Control.Monad.Trans.State | |
import Control.Monad.Trans.Writer.CPS | |
import Data.Foldable | |
import qualified Data.IntMap as IM |
This file contains hidden or 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
import Control.Monad.Except | |
import Control.Monad.State | |
import qualified Data.IntMap as IntMap | |
import qualified Data.IntSet as IntSet | |
import qualified Data.Map as Map | |
data Exp | |
= EVar String | |
| ELit Lit | |
| EApp Exp Exp |
This file contains hidden or 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 <assert.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
#include <algorithm> | |
#include <iostream> | |
#include <map> | |
#include <sstream> | |
#include <string> |
This file contains hidden or 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
import sys | |
import itertools | |
def next_power_of_two(v): | |
# From Stanford bit-twiddling hacks: https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 | |
v -= 1 | |
v |= v >> 1 | |
v |= v >> 2 | |
v |= v >> 4 | |
v |= v >> 8 |
This file contains hidden or 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 <algorithm> | |
#include <array> | |
#include <stddef.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
static const size_t STACK_SIZE = 16777216; | |
static const size_t DEFAULT_THREADS = 4; | |
struct Runtime; |
This file contains hidden or 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 <stdlib.h> | |
unsigned pext_utf8_decode(unsigned char*& buf) { | |
unsigned next4; | |
__builtin_memcpy(&next4, buf, 4); | |
next4 = __builtin_bswap32(next4); | |
if (__builtin_expect(!!(next4 >> 31), 0)) { | |
// multi-byte handling | |
unsigned r; | |
if (((next4 >> 16) & 0b11100000'11000000) == 0b11000000'10000000) { |
This file contains hidden or 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
module Cumulative | |
( makeCumulative | |
, makeCumulativeReverse | |
) where | |
import Data.Traversable | |
import Data.Monoid | |
-- | Make a traversable data structure cumulative by performing a left-biased | |
-- partial sum (actually a monoidal append). Linear time. |
This file contains hidden or 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 <bitset> | |
#include <iomanip> | |
#include <iostream> | |
#include <string.h> | |
namespace { | |
template <typename Floating, typename Integral, int expBits> | |
void explain(Floating x) { | |
static_assert(sizeof(Floating) == sizeof(Integral), | |
"types not the same size"); |
This file contains hidden or 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 #-} | |
{-# LANGUAGE NoMonoLocalBinds #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE ViewPatterns #-} | |
module FRM | |
( FastRangeMconcat | |
, fromVector | |
, toVector | |
, (!), (!?) |
NewerOlder