Skip to content

Instantly share code, notes, and snippets.

View littleli's full-sized avatar

Aleš Najmann littleli

View GitHub Profile
@littleli
littleli / truffle-material.md
Created December 28, 2017 16:39 — forked from smarr/truffle-material.md
Truffle: Languages and Material
;; Count a sequence
(fn [coll]
(reduce (fn [c _] (inc c)) 0 coll))
(fn [coll]
(reduce conj '() coll))
(fn [num]
(take num (map first (iterate (fn [[a b]] [b (+' a b)]) [1 1]))))
(fn [input]
(if (coll? input)
(= input (reverse input))
(= input (clojure.string/join "" (reverse input)))))
@littleli
littleli / transducers.md
Created April 17, 2019 16:59 — forked from pjstadig/transducers.md
The secret feature of transducers that no one talks about!

The Pledge

One thing that always made me a little sad about transducers was how map lost its ability to iterate multiple collections in parallel. This is actually my favorite feature of map. For example:

(map + (range 5) (range 5 10))
=> (5 7 9 11 13)

One somewhat practical use of this is if you want to compare two sequences, pairwise, using a comparator. Though I wish that every? took multiple collections, this is an adequate substitute:

@littleli
littleli / log.txt
Created November 24, 2019 19:18
clj-kondo/windows-tests
==== Testing JVM version
==== Testing JVM version
lein test clj-kondo.analysis-test
lein test clj-kondo.compojure-test
lein test clj-kondo.core-test
lein test :only clj-kondo.core-test/run!-test
# Check your changes compared to master with clj-kondo:
git diff `git merge-base origin/master HEAD` --name-only |grep -e '.clj$' | (cd `git root`; xargs clj-kondo --lint)
@littleli
littleli / clojure.rb
Created February 22, 2020 14:37
Clojure homebrew formula
class Clojure < Formula
desc "The Clojure Programming Language"
homepage "https://clojure.org"
url "https://download.clojure.org/install/clojure-tools-1.10.1.510.tar.gz"
sha256 "c6e003f612bdd7f9a9baa6d86deafb2d51b411310077c83c9ed13bc649c13b18"
revision 1
bottle :unneeded
depends_on "rlwrap"