Skip to content

Instantly share code, notes, and snippets.

final case class Matrix(s: String) {
private val matrix = fromString3(s)
def row(r: Int): Vector[Int] = {
matrix(r)
}
def column(c: Int): Vector[Int] = {
matrix.map(_(c))
@alienscience
alienscience / main.rs
Created January 20, 2019 10:21
Go like builder functions in Rust
trait Builder {
type Config : Default;
fn build(v: &[BuilderFn<Self::Config>]) -> Self::Config {
let mut ret = Default::default();
for c in v {
c(&mut ret)
}
ret
@alienscience
alienscience / fake-build.sh
Created July 29, 2018 08:53
A bash script that fakes a build -- used for testing CI
pwd
echo "Hello world"
sleep 1
echo "Goodbye world"
exit 3
(ns shell
"Run OS commands"
(:import [java.io BufferedReader InputStreamReader]))
(defn run
"Executes the given command"
[cmd]
(.. Runtime getRuntime (exec (str cmd))))
(defn pipe-to
(ns extended.sql
"Extensions to clojure.contrib.sql that handle autogenerated ids."
(:use clojure.contrib.sql)
;; TODO: change to clojure.contrib.string for 1.2
(:use [clojure.contrib.java-utils :only [as-str]]))
;;==== Internal functions ======================================================
(defn- join