By Scott Adams
We’ve won the war on boredom! If you have a smartphone in your pocket, a game console in the living room, a Kindle in your backpack and an iPad in the kitchen, you never need to suffer a minute without stimulation. Yay!
;; | |
;; NS CHEATSHEET | |
;; | |
;; * :require makes functions available with a namespace prefix | |
;; and optionally can refer functions to the current ns. | |
;; | |
;; * :import refers Java classes to the current namespace. | |
;; | |
;; * :refer-clojure affects availability of built-in (clojure.core) | |
;; functions. |
#Newbie programmer | |
def factorial(x): | |
if x == 0: | |
return 1 | |
else: | |
return x * factorial(x - 1) | |
print factorial(6) | |
#First year programmer, studied Pascal |
;;; http://srfi.schemers.org/srfi-26/srfi-26.html | |
(defn ^:private cut* | |
[[a f] form] | |
(cond | |
(nil? form) [a f] | |
(seq? (first form)) | |
(let [[arg-list xform] (cut* [[] '()] (first form))] | |
(recur [(reduce conj a arg-list) (concat f (list xform))] (next form))) |
(ns mars.rover) | |
;; A squad of robotic rovers are to be landed by NASA on a plateau on | |
;; Mars. | |
;; This plateau, which is curiously rectangular, must be navigated by the | |
;; rovers so that their on-board cameras can get a complete view of the | |
;; surrounding terrain to send back to Earth. |
(ns file-cols.core | |
"Print the source-line length histogram of a bunch of files as a histogram. | |
Inspired by: https://gist.github.com/rsms/36bda3b5c8ab83d951e45ed788a184f4" | |
(:require [clojure.java.io :as io])) | |
(def uni-bar | |
"Unicode bars for histogram." | |
["" "▏" "▎" "▍" "▌" "▋" "▊" "▉" "█"]) | |
(def quot-rem-8 |
Colossal Typewriter | |
by John McCarthy and Roland | |
Silver for the PDP-1 | Photon typesetter | |
? | editors by Michael | |
? \ Barnett & Kalon | |
Expensive Typewriter CREATE/EDIT \ Kelley for TECO | |
for PDP-1 by Steve Piner for CTSS \ IBM 704 for PDP-1 | |
/ | / | \ \__ \ by Dan Murphy | |
/ | / | \ \ \ | | |
* Expensive Typewriter editors EDITS | MEMO/MODIFY | | VEDIT | |
By Scott Adams
We’ve won the war on boredom! If you have a smartphone in your pocket, a game console in the living room, a Kindle in your backpack and an iPad in the kitchen, you never need to suffer a minute without stimulation. Yay!
(ns clj-spec-playground | |
(:require [clojure.string :as str] | |
[clojure.spec :as s] | |
[clojure.test.check.generators :as gen])) | |
;;; examples of clojure.spec being used like a gradual/dependently typed system. | |
(defn make-user | |
"Create a map of inputs after splitting name." | |
([name email] |
from gevent import monkey; monkey.patch_all() | |
import gevent | |
import gevent.greenlet | |
from functools import partial | |
from random import random | |
import urllib | |
import urllib2 | |
def on_exception(fun, greenlet): |
(ns prime-sieve | |
(:require [clojure.core.async :as async :refer [chan go <! >!]])) | |
;;; concurrent prime sieve in Clojure using core.async | |
;; inspired by a similar implementation in Go | |
;; http://golang.org/doc/play/sieve.go | |
(defmacro go-forever | |
"An infinite loop that runs in a go block." |