TDF is a binary format developed by the IGV team at Broad Institute.
Concepts
open StdLabels | |
type 'a tree = Node of ('a * 'a tree list) | |
let rec make ~f init = | |
let (label, forest) = f init in | |
Node (label, (List.map ~f:(make ~f) forest)) | |
and draw ~f (Node (label, forest)) = | |
let rec inner = function |
import time | |
from matplotlib import pyplot as plt | |
def timed(f, args, *, n_iter=100): | |
acc = float("inf") | |
for i in range(n_iter): | |
t0 = time.perf_counter() | |
f(*args) |
# Python 2 | |
>>> b = bytearray(8) | |
>>> v = memoryview(b) | |
>>> v[0] = 42 | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
TypeError: 'int' does not have the buffer interface | |
>>> b | |
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00') |
(* Chapter 2: BST *) | |
type 'a tree = Empty | Node of 'a tree * 'a * 'a tree | |
module Set : sig | |
val empty : 'a tree | |
val member : 'a tree -> 'a -> bool | |
val insert : 'a tree -> 'a -> 'a tree | |
end = struct |
>>> class A: | |
... def __init__(self, __foo): | |
... print(__foo) | |
... | |
>>> dis.dis(A.__init__) | |
3 0 LOAD_GLOBAL 0 (print) | |
2 LOAD_FAST 1 (_A__foo) | |
4 CALL_FUNCTION 1 | |
6 POP_TOP | |
8 LOAD_CONST 0 (None) |
>>> Error(abc.ABC, Exception): pass | |
... | |
>>> EndOfTheWorld(Exception): pass | |
... | |
>>> Error.register(EndOfTheWorld) | |
<class '__main__.EndOfTheWorld'> | |
>>> e = EndOfTheWorld() | |
>>> isintance(e, Error) | |
True | |
>>> try: |
import scala.{specialized => spec} | |
package object foo { | |
class ImplicitTest(val n: Nothing) extends AnyVal { | |
def foo[@spec(Double) T](size: Int)(f: Int => T): Array[T] = { | |
f(42) | |
??? | |
} | |
} | |
} |