This file contains hidden or 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
(* Polymorphic pairing heap. This should really be a functor such | |
that it can be made min/max/whatever *) | |
type 'a heap = Empty | Heap of 'a * ('a heap) list | |
let empty = Empty | |
let is_empty h = match h with | |
Empty -> true | |
| _ -> false |
This file contains hidden or 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
{-- Simple implementation of a pairing heap that supports safe | |
head, tail --} | |
module PairingHeap ( empty | |
, insert | |
, head | |
, tail | |
, meld | |
, safeHead | |
, safeTail |
This file contains hidden or 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
{* Simple implementation of a pairing heap that supports safe | |
head, tail *} | |
module PairingHeap ( empty | |
, insert | |
, head | |
, tail | |
, meld | |
, safeHead | |
, safeTail ) where |
This file contains hidden or 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
inline function foo(x, y) { | |
return x + y; | |
} | |
function bar(x, y) { | |
foo(1, 2); | |
return x * y; | |
} | |
// naively becomes => |
This file contains hidden or 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 itertools, sys | |
SPINNER = itertools.cycle(['-', '/', '|', '\\']) | |
def upload_callback(bytes_sent, bytes_total): | |
cols = 67 | |
if bytes_total > 0: | |
percent = bytes_sent / float(bytes_total) | |
else: | |
percent = 0 |
This file contains hidden or 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). | |
-export([pow/2, digitsum/1]). | |
pow(B, N) when is_integer(N), N >= 0 -> pow(B, N, 1). | |
pow(_, 0, A) -> A; | |
pow(B, N, A) -> pow(B, N-1, A*B). | |
digitsum(N) when is_integer(N) -> lists:sum([X - $0 || X <- integer_to_list(N)]). |
This file contains hidden or 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). | |
-export([pow/2, digitsum/1]). | |
pow(B, N) when is_integer(N), N >= 0 -> pow(B, N, 1). | |
pow(_, 0, A) -> A; | |
pow(B, N, A) -> pow(B, N-1, A*B). | |
digitsum(N) when is_integer(N) -> lists:foldl(fun (C, Acc) -> (C - $0) + Acc end, | |
0, integer_to_list(N)). | |
This file contains hidden or 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). | |
-export([pow/2]). | |
pow(B, N) when is_integer(N), N >= 0 -> pow(B, N, 1). | |
pow(_, 0, A) -> A; | |
pow(B, N, A) -> pow(B, N-1, A*B). |
This file contains hidden or 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 com.meetup.base.util import Web, U | |
import uuid | |
import random | |
def coin(): | |
return random.randint(0, 1) == 1 | |
def uuids(): | |
while True: | |
yield str(uuid.uuid4()) |
This file contains hidden or 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
(ns leiningen.hooks.classpath | |
(:require [clojure.string :as s] | |
[clojure.java.io :as f] | |
[robert.hooke] | |
[leiningen.classpath])) | |
(defn- get-jars [dir] | |
(if (.endsWith dir "*") | |
(for [jar (.listFiles (f/file (.substring dir 0 (- (count dir) 1)))) | |
:when (.endsWith (.getName jar) ".jar")] |