Skip to content

Instantly share code, notes, and snippets.

@damienzhang
damienzhang / numberplay.hs
Created March 14, 2018 20:35
Code for damienzhang.com/numberplay
import Data.List
import Text.Printf
choose :: Int -> [a] -> [[a]]
choose 0 _ = [[]]
choose _ [] = []
choose n (x:xs) = map (x :) (choose (n - 1) xs) ++ choose n xs
perm :: Int -> [a] -> [[a]]
perm n = concatMap permutations . choose n
module Main where
import Control.Monad
import Data.List (foldl')
data Operator
= Add
| Sub
| Mult
| Div
@damienzhang
damienzhang / hdf5build.sh
Last active December 25, 2015 21:49
Build the HDF5 library using local install of GCC and G++ with C++ library enabled.
CC='/sim/dev/sdz/tools/bin/gcc' \
CXX='/sim/dev/sdz/tools/bin/g++' \
./configure --prefix=/sim/dev/sdz/tools --enable-cxx
@damienzhang
damienzhang / gccbuild.sh
Last active December 22, 2015 11:28
How to build a local copy of GCC 4.7.3 (just C and C++) This is built without support for graphite loop optimizations.
wget ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.7.3/gcc-4.7.3.tar.bz2
tar xjf gcc-4.7.3.tar.bz2
cd gcc-4.7.3
./contrib/download_prerequisites
cd ..
mkdir build
cd build
export PREFIX=/sim/dev/sdz/tools