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
template <typename T> | |
struct point { unsigned int left; unsigned int top; }; | |
struct handle { | |
void *h; | |
}; | |
struct window_handle: handle {}; | |
struct screen_handle: handle {}; |
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 Cocoa | |
import Dispatch | |
typealias Scalar = Float | |
let fullCircle = Scalar.pi * 2 | |
let exponent = Int(CommandLine.arguments.dropFirst().first ?? "") ?? 5 | |
let fractions = stride(from: Scalar(0.0), |
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
data Tree a | |
= Empty | |
| Node a | |
(Tree a) | |
(Tree a) | |
rightmost :: Tree a -> [a] | |
rightmost = foldTree [] (\x l r -> x : zipPrefer r l) | |
foldTree :: b -> (a -> b -> b -> b) -> Tree a -> 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
using System; | |
using System.IO; | |
class RandomStream : Stream | |
{ | |
private readonly Random rng; | |
private long position = 0; | |
private readonly object advanceLock = new object(); |
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 Cocoa | |
typealias Scalar = Float80 | |
let speedOfLight: Scalar = 299792458 | |
let c = speedOfLight | |
struct MVector { | |
let time: Scalar | |
let x: Scalar |
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
from math import sin, cos, pi, sqrt | |
from itertools import count, product, takewhile | |
from multiprocessing import Pool | |
from functools import lru_cache | |
class Vector: | |
"""Vector arithmetic""" | |
def __init__(self, iterable): | |
self.elements = tuple(iterable) |
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
suffixes len fval | |
| len < 0 = [] | |
| fval < 0 = [] | |
| len == fval = [replicate len ')'] | |
| len < fval = [] | |
| len > fval = map ("(" ++) (suffix (len-1) (fval+1)) | |
++ | |
map (")" ++) (suffix (len-1) (fval-1)) | |
main :: IO() |
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 | |
import Data.List.GroupBy | |
data Group a = Single a | Interval a a | |
instance (Show a) => Show (Group a) where | |
show (Single i) = show i | |
show (Interval a b) = show a ++ "-" ++ show b | |
splitDisjoint = groupBy (\x y -> y == (x+1)) |