Basic Syntax 1;; Comments start with semicolon 2 3;; Variables (immutable by default) 4(def x 42) 5(def pi 3.14159) 6 7;; Functions 8(defn square [x] 9 (* x x)) 10 11(defn greet [name] 12 (str "Hello, " name "!")) 13 14;; Multi-arity functions 15(defn greet 16 ([] (greet "World")) 17 ([name] …
Read MoreBasic Syntax 1; Comments start with semicolon 2 3;; Variables 4(defvar global-var 42) ; Global variable (convention: name) 5(defparameter param 100) ; Always re-evaluated 6(let ((x 10) (y 20)) ; Local variables 7 (+ x y)) 8 9;; Constants 10(defconstant +pi+ 3.14159) ; Convention: +name+ 11 12;; Functions 13(defun …
Read MoreCollection of Lisp family language snippets including Common Lisp, Scheme, and Clojure. Topics Common Lisp Essentials - Common Lisp basics and useful patterns Scheme Essentials - Scheme programming fundamentals Clojure Essentials - Clojure for JVM development
Read MoreBasic Syntax 1; Comments start with semicolon 2 3;; Variables 4(define x 42) 5(define pi 3.14159) 6 7;; Functions 8(define (square x) 9 (* x x)) 10 11(define (factorial n) 12 (if (<= n 1) 13 1 14 (* n (factorial (- n 1))))) 15 16;; Lambda 17(lambda (x) (* x x)) 18((lambda (x) (* x x)) 5) ; => 25 19 20;; Let …
Read More