Skip to content

Instantly share code, notes, and snippets.

fn main() {
...
loop {
match handle.read_line(&mut buffer) {
Ok(bytes_read) => {
let mut object: Value = serde_json::from_str(&buffer).unwrap();
...

Keybase proof

I hereby claim:

  • I am xtrntr on github.
  • I am kangren (https://keybase.io/kangren) on keybase.
  • I have a public key ASA6RPyFUN9_c8iN5EBEnRtxKqKlexcJeeo_ExjET7hf8Ao

To claim this, I am signing this object:

bat_name bat_year
3 Battle of Carthage 698
5 Second Arab Siege of Constantinople 717
7 First Arab Siege of Constantinople 674
13 Battle of Baekgang 663
16 Battle of the North Cape 1943
66 Second Battle of Yeonpyeong 2002
73 Battle of Bubiyan 1991
80 Action in the Gulf of Sidra (1986) 1986
84 Battle of Seal Cove 1982
user> ; i guess that's the power of transducers, is that they let you transform the values going through an arbitrary reduction
user> ;; like if we were just going to take a list of chars and turn it into a list of chars, then we could just (map (cesar 3) list-of-chars)
user> ;; but what a transducer lets us do is take *any* reducing function (e.g. str, sum-string, or anything else we can thing of) and transform it according to some function we wrote
user> ;; my impression is that another thing thats cool about them is that they work on any "reducable" thing, not just lists of maps of w/e
user> ;; the most interesting example probably being core.async channels
user> ;; so i think we could use this (map (cesar 3)) thing to transform a core.async channel of characters into another one
user> ;; that would be a cool project actually, use core.async to write a network server where you can type characters into one end and they'll be encrypted on the other
user> ;; or like, have the user start it up with an ecryptio
(defn char-to-index [c] (- (int c) 97))
(defn index-to-char [n] (char (+ n 97)))
(defn cesar [n] #(char (mod (- (char-index %) n) 26)))
(transduce (map (cesar 10)) str "abc")
;; common reducing functions:
;; str, conj, +, cons, into
<html>
<head>
<script src="https://d3js.org/d3.v4.0.0-alpha.22.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
</head>
<body>
<script>
var ASCII = "01010100 01101000 01100101 00100000 01110001 01110101 01101001 01100011 01101011 00100000 01100010 01110010 01101111 01110111 01101110 00100000 01100110 01101111 01111000 00100000 01101010 01110101 01101101 01110000 01110011 00100000 01101111 01110110 01100101 01110010 00100000 01110100 01101000 01100101 00100000 01101100 01100001 01111010 01111001 00100000 01100100 01101111 01100111"
var CLOSURE_UNCOMPILED_DEFINES = null;
if(typeof goog == "undefined") document.write('<script src="js/compiled/out/goog/base.js"></script>');
document.write('<script src="js/compiled/out/cljs_deps.js"></script>');
document.write('<script>if (typeof goog == "undefined") console.warn("ClojureScript could not load :main, did you forget to specify :asset-path?");</script>');
document.write("<script>if (typeof goog != \"undefined\") { goog.require(\"figwheel.connect\"); }</script>");
document.write('<script>goog.require("cljs_d3.core");</script>');
function restart() {
// path (link) group
path = path.data(links);
// update existing links
path.classed('selected', function(d) { return d === selected_link; })
.style('marker-start', function(d) { return d.left ? 'url(#start-arrow)' : ''; })
.style('marker-end', function(d) { return d.right ? 'url(#end-arrow)' : ''; });
(defn point [n n-lst visited-n]
(let [res (for [next (map (fn [pair] (= n (first pair))) n-lst)
:when (not (some next visited-n))]
next)]
(println (some list? res))
res))
(defn walk [n1 n2 n-lst]
(loop [curr n1
visited '()]
(ns project-euler.core)
(def str "73167176531330624919225119674426574742355349194934969835203127745063262395783180169848018694788518438586156078911294949545950173795833195285320880551112540698747158523863050715693290963295227443043557668966489504452445231617318564030987111217223831136222989342338030813533627661428280644448664523874930358907296290491560440772390713810515859307960866701724271218839987979087922749219016997208880937766572733300105336788122023542180975125454059475224352584907711670556013604839586446706324415722155397536978179778461740649551492908625693219784686224828397224137565705605749026140797296865241453510047482166370484403199890008895243450658541227588666881164271714799244429282308634656748139191231628245861786645835912456652947654568284891288314260769004224219022671055626321111109370544217506941658960408071984038509624554443629812309878799272442849091888458015616609791913387549920052406368991256071760605886116467109405077541002256983155200055935729725716362695618826704282524836008232575304