traverse :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)
traverse_ :: (Foldable t, Applicative f) => (a -> f b) -> t a -> f ()
for :: (Traversable t, Applicative f) => t a -> (a -> f b) -> f (t b)
for_ :: (Foldable t, Applicative f) => t a -> (a -> f b) -> f ()
sequenceA :: (Traversable t, Applicative f) => t (f a) -> f (t a)
sequenceA_ :: (Foldable t, Applicative f) => t (f a) -> f ()
mapM :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b)
mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m ()
forM :: (Traversable t, Monad m) => t a -> (a -> m b) -> m (t b)
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
$include http://orteil.dashnet.org/randomgen/gens/names.txt | |
$name : Classical piece title generator | |
$author : Naïm Favier | |
$description : Generates a random classical music title. | |
$picture : http://i.imgur.com/YG6jDoC.png | |
$amount : 1 | |
$button : Compose! | |
$form |
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 python3 | |
from random import randint | |
size = 4 | |
score = 0 | |
grid = [[0 for i in range(size)] for i in range(size)] | |
def display(grid): | |
print() | |
for i in range(size): |
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
# to compile: | |
# gcc gaston.S -nostdlib -no-pie | |
#define SYS_WRITE 1 | |
#define SYS_OPEN 2 | |
#define SYS_CLOSE 3 | |
#define SYS_LSEEK 8 | |
#define SYS_SENDFILE 40 | |
#define SYS_SOCKET 41 | |
#define SYS_ACCEPT 43 |
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 python3 | |
import curses | |
import time | |
import random | |
SNAKE_COLOR, FOOD_COLOR = 1, 2 | |
UP, RIGHT, DOWN, LEFT = (0, -1), (1, 0), (0, 1), (-1, 0) | |
INITIAL_LENGTH = 10 | |
INITIAL_SPEED = 15 | |
SPEED_INCREMENT = 0.5 |
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 | |
channel=$1 | |
while read -rd ' ' time && read -rd ' ' event && IFS= read -r message; do | |
time=${time#[} time=${time%]} | |
case $event in | |
'***') | |
if [[ $message =~ ^(.*)' is now known as '(.*)$ ]]; then | |
event='*' |
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
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE ImpredicativeTypes #-} -- HIGHLY EXPERIMENTAL | |
import Data.Map (Map) | |
import qualified Data.Map as Map | |
import Data.Function | |
-- Say we want to define this function: | |
mergeKeys :: Map k a -> Map k b -> [k] | |
{- The obvious implementation is of course |
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 | |
# dependencies: bash 4+, jq | |
. ./config.sh | |
: "${verbose:=0}" | |
: "${syncplay_host:=syncplay.pl}" | |
: "${syncplay_port:=8999}" | |
: "${syncplay_nick:=syncplaybridge}" | |
: "${syncplay_room:?"can't be empty"}" | |
: "${irc_host:=chat.freenode.net}" |
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 -S nix-instantiate --eval --strict | |
# real 0m4.143s | |
with (builtins.getFlake "nixos").lib; | |
let | |
tails = l: if l == [] then [] else [ l ] ++ tails (tail l); | |
sum = foldl' (x: y: x + y) 0; | |
product = foldl' (x: y: x * y) 1; | |
lines = s: splitString "\n" (removeSuffix "\n" s); | |
nums = map toInt (lines (builtins.readFile ./input1)); |
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
{-# LANGUAGE LambdaCase #-} | |
module SevenTreesInOne where | |
import Test.QuickCheck | |
infixl :* | |
data T = O | T :* T | |
deriving (Eq, Ord, Show) | |
type T7 = (T, T, T, T, T, T, T) |
OlderNewer