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
cartesian :: [[a]] -> [[a]] | |
cartesian [] = [[]] | |
cartesian (xs:zss) = [x:ys | x <- xs, ys <- cartesian zss] |
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
BEGIN { FS = ";"; OFS = ","; } | |
{ name = $2; } | |
name ~ /<.*>/ { name = $11; } | |
name { print $1, name, $3; } |
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 <stdio.h> | |
const char clo[64] = { | |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 5, 6, | |
}; | |
const char b64[64] = { |
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 <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
static int pstrcmp(const void *, const void *); | |
int | |
main(void) | |
{ | |
char buf[BUFSIZ]; |
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 <array> | |
#include <tuple> | |
constexpr std::array<char, 4> base64(uint8_t octet0, uint8_t octet1, uint8_t octet2) | |
{ | |
constexpr std::array<char, 64> table = { | |
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', | |
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', | |
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', | |
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', '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
#include <type_traits> | |
namespace type_list { | |
class nil {}; | |
template<class Head, class Tail> | |
class cons {}; | |
// map 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
#include <stdint.h> | |
#include <string.h> | |
void | |
row_align(uint8_t *dst, const uint8_t *src, const size_t width_in_bits, const size_t height) | |
{ | |
const size_t width_in_whole_bytes = width_in_bits / 8; | |
if (width_in_bits % 32 == 0) { // word-aligned | |
memcpy(dst, src, width_in_whole_bytes * height); |
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
#!/bin/sh | |
expr="$1" | |
shift | |
pattern="$(printf "%s" "$expr" | sed -n 's/^s\/\(\([^\\\/]\|\\.\)*\)\/\([^\\\/]\|\\.\)*\/g\?$/\1/p')" | |
if [ -z "$pattern" ] | |
then | |
printf "usage: git sed s/lhs/rhs/[g] [file...]\n" > /dev/stderr |
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
exception NotFound | |
fun mk_idmap (mk_id : unit -> 'b) : ''a list -> ''a -> 'b = | |
foldl | |
(fn (x, acc) => | |
let val new_id = mk_id () in | |
fn id => if id = x then new_id else acc id | |
end) | |
(fn _ => raise NotFound) |
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 <stdio.h> | |
static const unsigned char braille[0x100] = { | |
0x40, 0x7c, 0x48, 0x70, 0x78, 0x68, 0x6f, 0x44, 0x58, 0x5c, 0x54, 0x56, 0x42, 0x64, 0x72, 0x4c, | |
0x7f, 0x61, 0x63, 0x69, 0x79, 0x71, 0x6b, 0x7b, 0x73, 0x6a, 0x52, 0x46, 0x66, 0x76, 0x74, 0x62, | |
0x00, 0x3c, 0x08, 0x30, 0x38, 0x28, 0x2f, 0x04, 0x18, 0x1c, 0x14, 0x16, 0x02, 0x24, 0x32, 0x0c, | |
0x3f, 0x21, 0x23, 0x29, 0x39, 0x31, 0x2b, 0x3b, 0x33, 0x2a, 0x12, 0x06, 0x26, 0x36, 0x34, 0x22, | |
0x6e, 0x41, 0x43, 0x49, 0x59, 0x51, 0x4b, 0x5b, 0x53, 0x4a, 0x5a, 0x45, 0x47, 0x4d, 0x5d, 0x55, | |
0x4f, 0x5f, 0x57, 0x4e, 0x5e, 0x65, 0x67, 0x7a, 0x6d, 0x7d, 0x75, 0x77, 0x50, 0x7e, 0x60, 0x6c, | |
0x2e, 0x01, 0x03, 0x09, 0x19, 0x11, 0x0b, 0x1b, 0x13, 0x0a, 0x1a, 0x05, 0x07, 0x0d, 0x1d, 0x15, |