Skip to content

Instantly share code, notes, and snippets.

View iduhetonas's full-sized avatar

Tyler Huffman iduhetonas

  • Bang & Olufsen
  • Copenhagen, Denmark
View GitHub Profile
/*
*
* Implementation using linked lists
*
*/
#ifndef ST_TREE_H
#define ST_TREE_H
#include "error.h"
@iduhetonas
iduhetonas / ParsecVsRegex.hs
Last active August 29, 2015 13:58
Difference between Parsec and Regex.
-- Parsing CVS, from RealWorldHaskell
csvFile = endBy line eol --Define a csvFile as a line that is terminated by an EOL character
line = sepBy cell (char ',') --Define a line as a group of cells separated by commas
cell = many (noneOf ",\n") --Define a cell as many characters that do not contain a comma and newline
eol = char '\n' --Define EOL character as a '\n' character
-- Regex equivalent
(?:^|,)(?=[^"]|(")?)"?((?(1)[^"]*|[^,"]*))"?(?=,|$)
@iduhetonas
iduhetonas / Prelude.max Question on Lists
Last active August 29, 2015 13:56
Confused about the Ord class for multi-dimensional lists.
-- This makes sense
Prelude> max 1 2
2
-- So does this
Prelude> max [1] [2]
[2]
-- Not really sure about this.
Prelude> max [1,2] [1]
@iduhetonas
iduhetonas / cabal_exec.txt
Created March 1, 2014 07:47
Cabal exec workaround
cabal() {
if [[ $1 == "exec" ]]
then
shift
local dir=$PWD conf db
while :; do
conf=$dir/cabal.sandbox.config
[[ ! -f $conf ]] || break
if [[ -z $dir ]]; then
echo "Cannot find cabal.sandbox.config" >&2