- High level overview https://yogthos.github.io/ClojureDistilled.html
- Interactive exercises http://clojurescriptkoans.com/
- More interactive exercises https://www.4clojure.com/
- Community-powered Clojure courses https://clojurecademy.com/
- Getting started guide https://grison.me/2020/04/04/starting-with-clojure/
- Interactive book https://www.maria.cloud/
- Interactive workbook http://viewer.gorilla-repl.org/view.html?source=github&user=lspector&repo=clojinc&path=worksheet.clj
- Clojure by example https://github.com/inclojure-org/clojure-by-example
This file contains hidden or 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 fun.clojure.paillier | |
(:import [java.math BigInteger] | |
[java.security SecureRandom] | |
[java.nio.charset StandardCharsets])) | |
(defn- random-number! [end] | |
(let [start (BigInteger/valueOf 2) | |
interval (.subtract end start) | |
i (BigInteger. (.bitCount interval) (SecureRandom.))] | |
(.add start i))) |
This file contains hidden or 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
package sandbox; | |
import java.util.Arrays; | |
import java.util.Random; | |
public class SoABenchmark { | |
public static Random rand = new Random(9001); | |
public static int NUM_LABELS = 10; | |
public static Struct[] aos; |
This file contains hidden or 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
clj::littleli.clj-dremel=> | |
; Syntax error compiling deftype* at (src/littleli/clj_dremel.clj:50:1). | |
; Unable to resolve symbol: IDeref in this context | |
[{:file "Compiler.java" :line 7115 :method "analyzeSeq" :flags [:tooling :java]} | |
{:file "Compiler.java" :line 6789 :method "analyze" :flags [:tooling :java]} | |
{:file "Compiler.java" :line 6745 :method "analyze" :flags [:dup :tooling :java]} | |
{:file "Compiler.java" :line 6118 :method "parse" :flags [:tooling :java]} | |
...] |
This file contains hidden or 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 strdist | |
(:require [clojure.core.match :refer [match]] | |
[clojure.string :as str])) | |
(defn -distance | |
[s1 s2] | |
(match [s1 s2] | |
[nil _] (.length s2) | |
[_ nil] (.length s1) | |
[([l & ls] :seq) ([r & rs] :seq)] (min (+ (if (= l r) 0 1) (-distance ls rs)) |
I looked into the state of GraalVM and Clojure and wrote some small work-related scripts.
- Downloaded GraalVM and set $GRAALVM_HOME
- Found two main libraries for building GraalVM CLIs - https://github.com/luchiniatwork/cambada#packaging-as-a-native-image and https://github.com/taylorwood/clj.native-image (or https://github.com/taylorwood/lein-native-image for the lein equivalent). I chose clj.native-image as it seemed more focused on doing one thing well.
- First tried its template example which was easy to follow.
- Then added a graalvm build to one of our small cli tools
- Found it to be pretty straightforward except for a stdout flushing issue that was trivial to fix
This file contains hidden or 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
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" |
This file contains hidden or 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
# 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) |
This file contains hidden or 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
==== 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 |
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: