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
-- Forked from http://stackoverflow.com/a/21246951 | |
{-# LANGUAGE Arrows #-} | |
import Text.XML.HXT.Core | |
import qualified Data.Map.Strict as M | |
-- data types | |
type Color = String | |
type Coord = (Double,Double,Double,Double) -- (x,y,w,h) | |
type Visual = (String,Maybe Color,Stroke) -- (glyph,fill,stroke) | |
type Stroke = (Maybe Color,Double) -- (color,width) |
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
def Integers(): | |
n = 0 | |
while True: | |
yield n | |
n += 1 | |
def Universe(): | |
for s in Integers(): | |
for a in Integers(): | |
if a>s: break |
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 collections import deque | |
class hashabledict(dict): | |
def __hash__(self): | |
return hash(tuple(sorted(self.items()))) | |
def dictFromChar2D(c2d=[], filtr=lambda _:True): | |
return { | |
(x,y):c | |
for y,c1d in zip(range(len(c2d)),c2d) |