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 -*- | |
""" | |
Incomplete RFC 2617 implementation for Tornado web server [1], originally | |
implemeted as `curtain` by Brian K. Jones [2]. | |
[1] http://tornadoweb.org | |
[2] http://github.com/bkjones/curtain | |
""" |
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
coffee> f = ([x, y]) -> x + y | |
[Function] | |
coffee> f([1, 2]) | |
3 | |
coffee> f = ({x, y}) -> x + y | |
[Function] | |
coffee> f({x: 1, y: 2}) | |
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
>>> map(lambda (x, y): x + y, ([1, 2], [3, 4])) | |
[3, 7] | |
>>> map(lambda (x, y): x + y, [xrange(2)]) | |
[1] | |
>>> def g(): | |
... yield 1 | |
... yield 2 | |
... | |
>>> map(lambda (x, y): x + y, [g()]) | |
[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
#use "topfind" | |
#require "oasis.base" | |
open OASISTypes | |
open OASISVersion | |
let (|>) x f = f x | |
let find_all_depends = | |
let rec inner acc = function |
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
# PyPy | |
>>>> 0 is 0 | |
True | |
>>>> x = 0 | |
>>>> x is 0 | |
False | |
# CPython | |
>>> 0 is 0 | |
True |
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
(* 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 |
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
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 |
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 |
OlderNewer