Here's the prime sieve of eratosthenes implemented in 4 different functional languages.
Which one's your favorite?
let rec range s e = if s > e then [] else s :: range (s + 1) e;;
let countprimes n =
let rec aux count = function
(ns savage.core | |
(:require-macros [reagent.ratom :refer [reaction]]) | |
(:require [reagent.core :as reagent :refer [cursor atom track track!]] | |
[reagent.ratom :refer [make-reaction]] | |
[clojure.set :as set] | |
[clojure.string :as string])) | |
(enable-console-print!) | |
(defn sqrt [x] (.sqrt js/Math x)) |
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
ipythonPort = 8001 # Ipython port to forward (also set in IPython notebook config) | |
Vagrant.configure(2) do |config| | |
config.ssh.insert_key = true | |
config.vm.define "sparkvm" do |master| | |
master.vm.box = "sparkmooc/base2" | |
master.vm.box_download_insecure = true |
#!/bin/bash | |
# source: http://blog.yohanliyanage.com/2015/05/docker-clean-up-after-yourself/ | |
# clean up exited containers | |
docker rm -v $(docker ps -a -q -f status=exited) | |
# clean up dangling images | |
docker rmi $(docker images -f "dangling=true" -q) | |
# clean up volumes |
package main | |
import ( | |
"image" | |
"image/color" | |
"image/png" | |
"log" | |
"math" | |
"math/rand" | |
"os" |
An Android app that allows Columbia students to locate their friends on campus in real-time.
### Nginx configuration for Node | |
upstream nodejs { | |
server 127.0.0.1:8081; | |
keepalive 256; | |
} | |
server { | |
listen 80; |
#!/usr/bin/python | |
import unittest | |
## binary tree problems | |
### A NODE OBJECT | |
class Node(object): | |
def __init__(self, data): | |
self.data = data | |
self.left = None |
from collections import deque | |
from sys import maxint as MAXINT | |
# Breadth first search | |
def bfs(graph, start): | |
explored, queue = set([start]), deque([start]) | |
while len(queue): | |
vertex = queue.popleft() | |
yield vertex | |
for neighbor in graph[vertex]: |