- High level overview https://yogthos.github.io/ClojureDistilled.html
- An Animated Introduction to Clojure https://markm208.github.io/cljbook/
- Interactive tutorial in a browser https://tryclojure.org/
- Interactive exercises http://clojurescriptkoans.com/
- Clerk notebooks with introductory examples https://github.clerk.garden/anthonygalea/notes-on-clojure
- More interactive exercises https://4clojure.oxal.org/
- Lambda Island tutorials https://lambdaisland.com/
- Functional Programming with Clojure resources https://practicalli.github.io/
| function downloadCanvasAsImage(canvas, filename){ | |
| let a = document.createElement("a") | |
| a.href = canvas.toDataURL() | |
| a.download = filename | |
| a.dispatchEvent(new MouseEvent("click")) | |
| } |
Short write up on using REPL when developing UIs in ClojureScript.
Everyone's standard approach to hot-reloading is to use a tool (Figwheel or shadow-cljs) that reloads changed namespaces automatically. This works really well: you change the code, the tool picks up changed files, compiles namespaces and dependants, notifies REPL client which then pulls in compiled changes, and re-runs a function that re-renders UI.
The other approach is to use ClojureScript's REPL directly and rely only on eval from the editor. This more or less matches Clojure style workflow. This approach might be useful when you don't want tools overhead or hot-reloading becomes slow for you or you just used to this style of interactions. Also changing code doesn't always mean that you want to reload all the changes. On the other hand it is very easy to change a couple of top-level forms and forget to eval one of them.
roots of a quadratic equation
Quadratic equations can be represented by three numbers, a, b, and c, which are the coefficient of x^2, the coefficient of x, and the constant term. The roots of a quadratic equation are everywhere where it touches the x axis, meaning the equation is equal to zero.
You can use the quadratic formula which calculates the roots. In fact, that's your task: write a function that returns the roots of a quadratic equation using the quadratic formula. Here is more information about it.
Note: you don't have to return complex roots if the curve does not cross the x-axis.
Thanks to this site for the challenge idea where it is considered Medium level in Python.
| #!/usr/bin/env bb | |
| (ns vidwiz.main | |
| "This is a prototype script for automating a portion of my video editing using ffmpeg." | |
| (:require [clojure.java.shell :refer [sh]] | |
| [clojure.string :as st] | |
| [cheshire.core :refer [parse-string]])) | |
| ;; util | |
| (defn get-extension |
Dijkstra's Algorithm
Write a function to calculate the shortest path between two nodes in a graph using Dijkstra's Algorithm. The graph is directional and is represented as a map. The keys are pairs of nodes and the value is the cost to traverse the edge between them, from the first node to the second node. If a pair of nodes does not exist in the map, it means that there is no edge between them.
Example graph
(def graph {[:a :b] 1
[:a :c] 2
[:c :a] 4})| (ns aoc21-01 | |
| (:require [clojure.string :as str])) | |
| (def input (map parse-long (str/split-lines (slurp "input.txt")))) | |
| (defn answer-01 [input] | |
| (count (filter true? (map < input (rest input))))) | |
| (def three-sliding-window | |
| (map + input (next input) (nnext input))) |
- Quil Graphics and animation sketches, based on Processing
- th.ing/geom a comprehensive and modular geometry & visualization toolkit. WebGL, OpenGL, SVG.
- Iglu Turning data into GLSL shaders for use by OpenGL and WebGL. By Zach Oakes, part of play-cljc.
| #!/usr/bin/env bb | |
| ;; You need to have an OpenAI API key and set it like: | |
| ;; export OPENAI_API_KEY=<your key> in your .bashrc | |
| ;; | |
| ;; Make sure you have babashka installed | |
| ;; https://github.com/babashka/babashka#installation | |
| ;; | |
| ;; One way to run this is to install bbin | |
| ;; https://github.com/babashka/bbin |