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
(** Task X: Treap. *) | |
module Treap = struct | |
type ('a, 'b) t = | |
| Empty | |
| Node of ('a, 'b) t * 'a * 'b * ('a, 'b) t | |
let empty = Empty | |
let rec merge l r = match (l, r) with |
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
# module M = Map.Make((val (module String : Map.OrderedType) : Map.OrderedType));; | |
module M : | |
sig | |
type key | |
type +'a t | |
end | |
# module M = Map.Make(String);; | |
module M : | |
sig | |
type key = String.t |
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 f((x, y)): return x + y | |
... | |
>>> def gen(): | |
... yield 1 | |
... yield 2 | |
... | |
>>> | |
>>> f(gen()) | |
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
# -*- coding: utf-8 -*- | |
# from __future__ import print_function | |
import csv | |
import itertools | |
import errno | |
import os | |
import os.path | |
import sys |
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
# See http://bioinformatics-renlab.ucsd.edu/rentrac/wiki/ChromaSig | |
sub init_gibbs_seed { | |
# ... | |
# print("score = $score\n"); | |
# my ($seed, $ave_dist) = tournament_sort($id, $profiles_c, | |
# $clusters_arrayref, $filtered_data); | |
# my $norm = $sorted_norm[$percentile + $i * $interval]->{norm}; | |
# my $score = $norm / $ave_dist; |
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 foo(): | |
try: | |
foo() | |
finally: | |
foo() | |
# >>> foo() | |
# ??? |
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
# -*- coding: utf-8 -*- | |
from collections import MutableSequence | |
def trace(f): | |
def inner(*args, **kwargs): | |
print(f.__name__) | |
return f(*args, **kwargs) | |
return inner |
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 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) | |
??? | |
} | |
} | |
} |
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
>>> Error(abc.ABC, Exception): pass | |
... | |
>>> EndOfTheWorld(Exception): pass | |
... | |
>>> Error.register(EndOfTheWorld) | |
<class '__main__.EndOfTheWorld'> | |
>>> e = EndOfTheWorld() | |
>>> isintance(e, Error) | |
True | |
>>> try: |
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
>>> 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) |