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
push = (element) -> (stack) -> | |
newStack = [element].concat stack | |
{value: element, stack: newStack} | |
pop = (stack) -> | |
element = stack[0] | |
newStack = stack.slice 1 | |
{value: element, stack: newStack} | |
bind = (stackOperation, continuation) -> (stack) -> |
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(mini_chat). | |
-compile(export_all). | |
-define(ACTIVE_OPTIONS, [{reuseaddr, true}]). | |
% Commands start with "/", char 47 | |
is_command(Str) -> hd(Str) =:= 47. | |
chatroom(Users) -> | |
process_flag(trap_exit, 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
(ns sudoku | |
(:refer-clojure :exclude [==]) | |
(:use clojure.core.logic)) | |
(defn get-square [rows x y] | |
(for [x (range x (+ x 3)) | |
y (range y (+ y 3))] | |
(get-in rows [x y]))) | |
(defn init [vars hints] |
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
// timer | |
// console.time('fib'); | |
// console.timeEnd('fib'); | |
//Recursive fibonnaci | |
var fib_recur = function (n) { | |
if (n == 0) return 0; | |
if (n == 1) return 1; | |
return fib_recur(n-1) + fib_recur(n-2); | |
}; |
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 messagepassing.core) | |
(import [java.util.concurrent LinkedTransferQueue]) | |
(def m 10000000) | |
(defn queue-test [] | |
(defn bounce [in out m] | |
(let [value (.take in)] | |
(if (< value m) | |
(do |
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
var cluster = require('cluster'); | |
var m = 10000000; | |
function bounce(msg, out) { | |
if (msg < m) { | |
out.send(msg + 1); | |
return null; | |
} else { | |
console.log("Finished with", msg); |
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
// New is a function that takes a function F | |
function New (F) { | |
var o = {}; // and creates a new object o | |
o.__proto__ = F.prototype // and sets o.__proto__ to be F's prototype | |
// New returns a function that... | |
return function () { | |
F.apply(o, arguments); // runs F with o as "this", passing along any arguments | |
return o; // and returns o, the new object we created | |
} |
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 json, pycurl, subprocess | |
class ChatStream(object): | |
def __init__(self, sessid, handler): | |
self.handler = handler | |
self.buffer = '' | |
self.curl = pycurl.Curl() | |
self.curl.setopt(pycurl.URL, 'https://irccloud.com/chat/stream') | |
self.curl.setopt(pycurl.COOKIE, 'session=' + sessid) | |
self.curl.setopt(pycurl.WRITEFUNCTION, self.chunk) |