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
#include <stdio.h> | |
/* | |
* Calculates what Ada Lovelace labeled "B7", which today we would call the 8th | |
* Bernoulli number. | |
*/ | |
int main(int argc, char* argv[]) | |
{ | |
// ------------------------------------------------------------------------ | |
// Data |
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
(defmacro as-some-> | |
"Hybrid of as-> and some->." | |
[expr name & forms] | |
(let [steps (map (fn [step] `(if (nil? ~name) nil (-> ~name ~step))) | |
forms)] | |
`(let [~name ~expr | |
~@(interleave (repeat name) (butlast steps))] | |
~(if (empty? forms) | |
name | |
(last steps))))) |
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
;; I think it would be a mistake to introduce temporal coupling to prevent typos. | |
;; The example program below lets you identify "missing" keys specs at | |
;; the time and place of your choosing, and then handle them as you | |
;; deem appropriate, without imposing those decisions on other | |
;; users of spec. | |
(require '[clojure.spec.alpha :as s] | |
'[clojure.set :as set]) |
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 React, { PropTypes, Component } from 'react' | |
import styles from './../styles/Collapse.scss' | |
class Collapse extends Component { | |
static propTypes = { | |
open: PropTypes.bool, | |
className: PropTypes.string, | |
} |
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
;; Happens sometimes when clojure.pprint/simple-dispatch or clojure.pprint/print-method | |
;; or whatnot don't have a stated preference for an object type that matches multiple | |
;; dispatch values. Here's a way around that. | |
;; Define a type that will match multiple dispatch values (IDeref & IPersistentMap) | |
user> (defrecord Foo [bar] | |
clojure.lang.IDeref | |
(deref [this] | |
(if bar | |
this |
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 simplequest.core) | |
(defn -main | |
"I don't do a whole lot ... yet." | |
[& args] | |
(println "Hello, World!")) |
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
Android Emulator usage: emulator [options] [-qemu args] | |
options: | |
-sysdir <dir> search for system disk images in <dir> | |
-system <file> read initial system image from <file> | |
-datadir <dir> write user data into <dir> | |
-kernel <file> use specific emulated kernel | |
-ramdisk <file> ramdisk image (default <system>/ramdisk.img | |
-image <file> obsolete, use -system <file> instead | |
-initdata <file> same as '-init-data <file>' | |
-data <file> data image (default <datadir>/userdata-qemu.img |
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 tree-seq-depth | |
"Returns a lazy sequence of vectors of the nodes in a tree and their | |
depth as [node depth], via a depth-first walk. branch? must be a fn | |
of one arg that returns true if passed a node that can have | |
children (but may not). children must be a fn of one arg that | |
returns a sequence of the children. Will only be called on nodes for | |
which branch? returns true. Root is the root node of the tree." | |
[branch? children root] | |
(let [walk (fn walk [depth node] | |
(lazy-seq |
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
(comment ; Fun with transducers, v2 | |
;; Still haven't found a brief + approachable overview of Clojure 1.7's new | |
;; transducers in the particular way I would have preferred myself - so here goes: | |
;;;; Definitions | |
;; Looking at the `reduce` docstring, we can define a 'reducing-fn' as: | |
(fn reducing-fn ([]) ([accumulation next-input])) -> new-accumulation | |
;; (The `[]` arity is actually optional; it's only used when calling | |
;; `reduce` w/o an init-accumulator). |