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
import Data.List (sort, permutations, elemIndex) | |
data Card = Card Suit Int | |
deriving (Show, Eq, Ord) | |
data Suit = Spades | Clubs | Hearts | Diamonds | |
deriving (Show, Eq, Ord) | |
suits = [Spades, Clubs, Hearts, Diamonds] |
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
import Data.Functor.Identity | |
import Text.Parsec | |
import Text.Parsec.Indent | |
example1 = "asdf(1 2 3):\n foo\n x:\n y\n z:\n q\n a" | |
-- Data structures | |
data Tree = Node [Value] [Tree] |
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
import System.IO (hFlush, stdout) | |
main :: IO () | |
main = do | |
putStr "enter a number> " | |
hFlush stdout | |
line <- getLine | |
runNested (read line) True | |
-- a will be the type Bool wrapped in a List n times by the end |
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
import Control.Monad (foldM) | |
import Control.Monad.State (StateT, modify, get, put, lift, evalStateT) | |
import Data.Map (Map) | |
import qualified Data.Map as Map | |
data KindExpr | |
= TCon String | |
| TVar String | |
| TAp KindExpr KindExpr | |
deriving (Show) |
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
import re | |
from ctypes import c_long, CFUNCTYPE | |
import llvmlite.binding as llvm | |
from llvmlite import ir | |
llvm.initialize() | |
llvm.initialize_native_target() | |
llvm.initialize_native_asmprinter() |
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 | |
set -e | |
function prompt() { | |
B="$1" | |
read -p 'Delete? [y/n/s] ' result | |
case "$result" in | |
y) |
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
(global-set-key (kbd "s-k") 'point-to-register) | |
(global-set-key (kbd "s-j") 'jump-to-register) |
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
use std::env; | |
use std::fs; | |
fn get_arg() -> String { | |
let opt_filename = env::args().nth(1); | |
match opt_filename { | |
Some(f) => f, | |
None => "example".into(), | |
} | |
} |
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
use std::collections::HashMap; | |
use std::collections::HashSet; | |
use std::cmp::Ordering; | |
use std::env; | |
use std::fs; | |
fn get_arg() -> String { | |
let opt_filename = env::args().nth(1); | |
match opt_filename { | |
Some(f) => f, |
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
use std::env; | |
use std::fs; | |
use std::collections::HashSet; | |
fn main() { | |
let map = split_lines(get_content(get_arg())); | |
println!("Part 1: {}", part1(&map)); | |
println!("Part 2: {}", part2(&map)); | |
} |