Skip to content

Instantly share code, notes, and snippets.

View hyphenrf's full-sized avatar

Haz hyphenrf

  • Egypt
View GitHub Profile
let rec perm = function
| [] -> []
| [x] -> [[x]]
| xs ->
let rec aux i ls =
let (l,r) = splitat i ls in
match r with
| [] -> []
| h::r_ ->
let rest = l @ r_ in
@hyphenrf
hyphenrf / xxd-r.hs
Last active May 9, 2021 00:45
a utility equivalent to `xxd -r -ps` for systems with limited xxd implementations
{-# language OverloadedStrings #-}
import Prelude hiding (getLine, putStr, filter, length, take, drop)
import Data.ByteString
import Data.Maybe
main = do
ln <- getLine
putStr $ f ln -- putStr and getLine from ByteString
#> shell doesn't have multiline comments
: <<comment
ok
buddy
here's
your
multiline
comment
@hyphenrf
hyphenrf / pyfun.py
Created April 20, 2021 11:52
Does this make you angry?
import functools
c = lambda f: lambda g: lambda x: f (g (x))
add = lambda x: lambda y: x + y
const = lambda x: lambda y: x
uncurry = lambda f: lambda x, y: f (x) (y)
succ = add (1)
fold = lambda f: lambda z: lambda xs: functools.reduce(uncurry(f), xs, z)
len = fold (c (const) (succ)) (0)
@hyphenrf
hyphenrf / upsize
Last active May 19, 2021 01:34
get eopkg update size in per-package detail
#!/usr/bin/env python2
from pisi.api import *
from pisi.util import human_readable_size
from os.path import basename as b
from sys import argv
ctx = set()
Walter Bright's MEM Package
---------------------------
PREFACE:
--------
The files, MEM.H and MEM.C which constitute the MEM package were originally
published in the March-April 1990 edition of Micro Cornucopia magazine, now
sadly out of print. The files as they appear in SNIPPETS have been edited