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
(definterface INode | |
(getCar []) | |
(getCdr []) | |
(setCar [x]) | |
(setCdr [x]) | |
(valAt [i])) | |
(deftype Node [^:volatile-mutable car ^:volatile-mutable cdr] | |
INode | |
(getCar [_] car) |
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
(definterface INode | |
(getCar []) | |
(getCdr []) | |
(setCar [x]) | |
(setCdr [x]) | |
(valAt [i])) | |
(deftype Node [^:volatile-mutable car ^:volatile-mutable cdr] | |
INode | |
(getCar [_] car) |
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
(definterface INode | |
(getCar []) | |
(getCdr []) | |
(setCar [x]) | |
(setCdr [x])) | |
(deftype Node [^:volatile-mutable car ^:volatile-mutable cdr] | |
INode | |
(getCar [_] car) | |
(getCdr [_] cdr) |
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 java.util.Arrays; | |
class DynamicArray<E> { | |
private transient Object[] elementData; | |
private int size; | |
private int modCount = 0; | |
private int a = 2; | |
public DynamicArray(int initialCapacity) { | |
if (initialCapacity < 0) |
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 Node<T> { | |
// data cell, i.e. car | |
public T car; | |
// pointer or next cell, i.e. cdr | |
public Node cdr; | |
public Node(T car) { | |
this.car = car; | |
} |
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
(ns gogo.core | |
(:require [clojure.core.async :refer [go]])) | |
;; ## Macros Wrapping Macros | |
;; | |
;; `gogo` is a tiny, simple macro library that wraps the `go` macro of | |
;; `clojure.core.async`. Its purpose is to provide helpers after the fashion of | |
;; things like `when-let` and `if-let`. |
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 rauth.service import OAuth1Service | |
# Get a real consumer key & secret from https://dev.twitter.com/apps/new | |
twitter = OAuth1Service( | |
name='twitter', | |
consumer_key='J8MoJG4bQ9gcmGh8H7XhMg', | |
consumer_secret='7WAscbSy65GmiVOvMU5EBYn5z80fhQkcFWSLMJJu4', | |
request_token_url='https://api.twitter.com/oauth/request_token', | |
access_token_url='https://api.twitter.com/oauth/access_token', | |
authorize_url='https://api.twitter.com/oauth/authorize', |
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 conn (with-connection ["irc.example.com" 6667 "foo" "bar" "Foo Bar"] | |
(defcallback foo [{:keys [command]}] | |
(println command)))) | |
(run conn) |
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
(defn add-row [cnt acc] | |
(let [prev (last acc)] | |
(loop [n 0 row []] | |
(if (= n cnt) | |
row | |
(let [a (nth prev (- n 1) 0) | |
b (nth prev n 0)] | |
(recur (inc n) (conj row (if (zero? (+ a b)) 1 (+ a b))))))))) | |
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
(require '[clojure.java.io :as io]) | |
(import [java.net Socket]) | |
(def irc (agent {:socket (Socket. "irc.strangeloop.io" 7000)})) | |
(send irc (fn [{:keys [socket]}] | |
(doseq [line (line-seq (io/reader socket))] | |
(println line)))) |