I hereby claim:
- I am dexterous on github.
- I am saagermhatretw (https://keybase.io/saagermhatretw) on keybase.
- I have a public key ASCjkQF0HpQb9GHrWxwaG1XmCcxpHtk3fBSNw49vTAPEzAo
To claim this, I am signing this object:
| (defn factors! [n] | |
| (when-not (integer? n) | |
| (throw (IllegalArgumentException. | |
| (format "`%s` is not a natural number." (pr-str n))))) | |
| (loop [n n, c (biginteger 2), fs (transient [])] | |
| (cond | |
| (neg? n) (recur (- n) c (conj! fs -1)) | |
| (> c n) (seq (persistent! fs)) ; XXX: only #{0, 1} | |
| (> c (Math/sqrt n)) (seq (persistent! (conj! fs n))) | |
| (zero? (rem n c)) (recur (/ n c) c (conj! fs c)) |
| import java.util.Collections; | |
| import java.util.Objects; | |
| import java.util.Set; | |
| import java.util.stream.Collectors; | |
| class Employee { | |
| private Set<Org> orgs; | |
| private Org primaryOrg; |
| // https://en.wikipedia.org/wiki/Combinatory_logic#Examples_of_combinators | |
| const I = a => a, // identity | |
| K = a => _ => a, // constantly | |
| V = a => b => c => c(a)(b), // cons | |
| B = a => b => c => a(b(c)), // compose | |
| S = x => y => z => x(z)(y(z)); // apply x to y inside env z | |
| // alternative implementation of identity | |
| const _I = S(K)(K) |
| package main | |
| import ( | |
| "context" | |
| "log" | |
| "runtime" | |
| "sync" | |
| "time" | |
| ) |
| ;; From https://github.com/ring-clojure/ring/blob/a915a44/ring-core/src/ring/middleware/session/cookie.clj#L29 | |
| (defn- hmac | |
| "Generates a Base64 HMAC with the supplied key on a string of data." | |
| [key data] | |
| (let [mac (Mac/getInstance hmac-algorithm)] | |
| (.init mac (SecretKeySpec. key hmac-algorithm)) | |
| (codec/base64-encode (.doFinal mac data)))) | |
| ;; I would prefer to write it like this. | |
| (defn- hmac |
| # CLOSURES IN RUBY Paul Cantrell https://innig.net | |
| # Email: username "paul", domain name "innig.net" | |
| # I recommend executing this file, then reading it alongside its output. | |
| # | |
| # Alteratively, you can give yourself an unreasonable Ruby test by deleting all | |
| # the comments, then trying to guess the output of the code! | |
| # | |
| # (Naive HR departments, please do not use that idea as a hiring quiz.) |
I hereby claim:
To claim this, I am signing this object:
| (defn rotate [v n] | |
| (cond | |
| (zero? n) v | |
| (pos? n) (vec (concat (nthrest v n) (take n v))) | |
| (neg? n) (rotate v (+ (count v) n)))) |
| (defn how-not-to-factorial [x] | |
| (condp #(< %2 %1) x | |
| 1 (throw (IllegalArgumentException.)) | |
| 3 x | |
| (loop [acc (bigint x) prev (dec x)] | |
| (if (= prev 2) (* acc 2) (recur (* acc prev) (dec prev)))))) | |
| ;; when you want to factorial... | |
| (defn just-factorial [n] (apply * (range 1N (inc n)))) |
@DevOpsSummit #CloudNative #Serverless #DevOps
BY JASON BLOOMBERG
APRIL 29, 2018 07:00 PM EDT
Guest post by Intellyx Principal Analyst Charles Araujo
I was at a conference recently when I saw it. I sighed and shook my head.