Skip to content

Instantly share code, notes, and snippets.

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]
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]
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
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)
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()
#!/usr/bin/env bash
set -e
function prompt() {
B="$1"
read -p 'Delete? [y/n/s] ' result
case "$result" in
y)
(global-set-key (kbd "s-k") 'point-to-register)
(global-set-key (kbd "s-j") 'jump-to-register)
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(),
}
}
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,
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));
}