Skip to content
HN On Hacker News ↗

Lisp: Common Lisp, Racket, Clojure, Emacs Lisp

▲ 187 points 46 comments by veqq 3d ago HN discussion ↗

Pangram verdict · v3.3

We believe that this document is fully human-written

1 %

AI likelihood · overall

Human
100% human-written 0% AI-generated
SEGMENTS · HUMAN 8 of 8
SEGMENTS · AI 0 of 8
WORD COUNT 1,781
PEAK AI % 1% · §4
Analyzed
May 18
backend: pangram/v3.3
Segments scanned
8 windows
avg 223 words each
Distribution
100 / 0%
human / AI fraction
Verdict
Human
Pangram v3.3

Article text · 1,781 words · 8 segments analyzed

Human AI-generated
§1 Human · 1%

ca side-by-side reference sheetgrammar and execution | variables and expressions | arithmetic and logic | strings | regular expressions | dates and time | lists | fixed-length arrays | dictionaries | user-defined types | functions | execution control | exceptions | streams | emacs buffers | files | directories | processes and environment | libraries and namespaces | objects | lisp macros | reflection | java interop common lisp racket clojure emacs lisp version used SBCL 1.2 Racket 6.1 Clojure 1.6 Emacs 24.5 show version $ sbcl --version $ racket --version displayed by repl on startup $ emacs --version grammar and execution common lisp racket clojure emacs lisp compiler $ raco make module.rkt M-x byte-compile-file standalone executable (sb-ext:save-lisp-and-die "executable" :executable t :toplevel 'function) $ mzc —exe executable file interpreter $ sbcl --script foo.lisp $ racket -r foo.racket specify full path to clojure jar: java -cp clojure.jar clojure.main foo.clj shebang #!/usr/bin/env sbcl --script #!/usr/bin/env racket --script specify full path to clojure jar: #!/usr/bin/env java -jar clojure.jar #!/usr/bin/env emacs --script repl $ sbcl $ racket $ java -jar /PATH/TO/clojure.jar M-x ielm command line program $ racket -e '(+ 1 1)' word separator whitespace whitespace whitespace and commas whitespace end-of-line comment (+ 1 1) ; adding (+ 1 1) ; adding (+ 1 1) ; adding (+ 1 1) ; adding multiple line comment (+ 1 #| adding |# 1) (+ 1 #| adding |# 1) variables and expressions common lisp racket clojure emacs lisp identifier case insensitive, cannot start with digit excluded characters: SP ( ) " , ' ` : ; # | \ reserved for user macros: ? ! [ ] { }

§2 Human · 0%

case sensitive, cannot start with digit excluded characters: SP ( ) [ ] { } " , ' ` ; # | \ case sensitive, cannot start with digit permitted characters: A-Z a-z 0-9 * + ! - _ ? these have special meaning or are reserved: / . : case sensitive, cannot start with digit excluded characters: SP ( ) " , ' ` ; # | \ _ [ ] quoted identifier and escaped identifier (setq |white space symbol| 3) (setq white\ space\ symbol 3) (define |white space symbol| 3) (define white\ space\ symbol 3) none none none (setq white\ space\ symbol 3) local variable ; parallel assignment: (let ((x 3) (y 4)) (+ x y)) ; sequential assignment: (let* ((x 3) (y (* x x))) (+ x y)) ; parallel assignment: (let ((x 3) (y 4)) (+ x y)) ; sequential assignment: (let* ((x 3) (y (* x x))) (+ x y)) (let [x 3 y 4] (+ x y)) (let [[x y] [3 4]] (+ x y)) (let [x 3 y (* x x)] (+ x y)) ; parallel assignment: (lexical-let ((x 3) (y 4)) (+ x y)) (lexical-let* ((x 3) (y (* x x))) (+ x y)) global variable (defparameter *x* 3) ; doesn't change x if already set: (defvar *x* 3) (define x 3) ; y is not global: (define (double z) (define y 2) (* y z)) (def x 3) (set 'x 3) (setq x 3) remove variable (makunbound 'x) (namespace-undefine-variable! 'x) (ns-unmap *ns* 'x) (makunbound 'x) null nil '() null '() ; same value as null in Java: nil nil '() null test (null x) (null?

§3 Human · 1%

x) (nil? x) (null x) identifier as value 'x (quote x) 'x (quote x) 'x (quote x) 'x (quote x) identifier test (symbolp 'x) (symbol? 'x) (symbol? 'x) (symbolp 'x) identifier equality test (eq 'x 'x) (eq? 'x 'x) (= 'x 'x) (eq 'x 'x) non-referential identifier :foo #:foo :foo :foo identifier attributes set, get, remove (set 'x 13) (setf (get 'x :desc) "unlucky") (get 'x :desc) (remprop 'x :desc) none ; value must be instance of clojure.lang.IObj: (def x (with-meta [13] {:desc "unlucky"})) (get (meta x) :desc) ; none (set 'x 13) (setf (get 'x :desc) "unlucky") (get 'x :desc) (remprop 'x :desc) arithmetic and logic common lisp racket clojure emacs lisp true and false t nil #t #f true false true false t nil falsehoods nil () #f false false nil nil () logical operators (or (not t) (and t nil)) (or (not #t) (and #t #f)) (or (not true) (and true false)) (or (not t) (and t nil)) relational operators = /= < > <= >= = none < > <= >= = not= < > <= >= = /= < > <= >= min and max (min 1 2 3) (max 1 2 3) (min 1 2 3) (max 1 2 3) (min 1 2 3) (max 1 2 3) (min 1 2 3) (max 1 2 3) numeric predicates numberp integerp rationalp floatp realp complexp number? integer? rational? inexact? real? complex? number? integer? rational? float?

§4 Human · 1%

none none numberp integerp none floatp none none arithmetic operators + - * / mod + - * / modulo + - * / mod + - * / % integer division and remainder (truncate 7 3) (rem 7 3) (quotient 7 3) (remainder 7 3) (quot 7 3) (rem 7 3) (/ 7 3) (% 7 3) integer division by zero division-by-zero error division by zero error arith-error float division rational: (/ 7 3) float: (/ 7 (* 3 1.0)) rational: (/ 7 3) float: (/ 7 (float 3)) rational: (/ 7 3) float: (/ 7 (* 3 1.0)) integer quotient: (/ 7 3) float: (/ 7 (* 3 1.0)) float division by zero division-by-zero error -1.0e+INF, -0.0e+NaN, or 1.0e+INF power (expt 2 32) (expt 2 32) returns float: (Math/pow 2 32) (expt 2 32) sqrt (sqrt 2) (sqrt 2) (Math/sqrt 2) (sqrt 2) sqrt -1 #c(0.0 1.0) 0+1i (Math/sqrt -1): NaN -0.0e+NaN transcendental functions exp log sin cos tan asin acos atan atan exp log sin cos tan asin acos atan atan Math/exp Math/log Math/sin Math/cos Math/tan Math/asin Math/acos Math/atan Math/atan2 exp log sin cos tan asin acos atan atan float truncation return two values, first is integer: truncate round ceiling floor return floats: truncate round ceiling floor return integers: int Math/round return floats: Math/ceil Math/floor truncate round ceiling floor fround fceiling ffloor truncate returns integer absolute value and signum abs signum abs racket: sgn Math/abs Math/signum abs signum integer overflow none; arbitrary-precision integers none; arbitrary-precision integers clojure.lang.

§5 Human · 0%

Numbers.throwIntOverflow exception float overflow floating-point-overflow error not literals: -Infity NaN Infinity rational construction (/ 3 7) ; literal: 3/7 (/ 3 7) ; literal: 3/7 ; also rational: 2.718 (exp 1) (/ 3 7) ; literal: 3/7 rational decomposition (numerator 3/7) (denominator 3/7) (numerator 3/7) (denominator 3/7) (numerator 3/7) (denominator 3/7) none none complex construction #c(1 2) 1+2i (+ 1 +2i) none none complex decomposition (realpart #c(1 2)) (imagpart #c(1 2)) (phase #c(1 2)) (abs #c(1 2)) (conjugate #c(1 2)) (real-part 1+2i) (imag-part 1+2i) (angle 1+2i) (magnitude 1+2i) (conjugate 1+2i) none none none none random number uniform integer, uniform float, normal float (random 100) (random 1.0) none (random 100) (random) none (def rnd (java.util.Random.)) (.nextInt rnd 100) (.nextFloat rnd) (.nextGaussian rnd) (random 100) none none random seed (setq *random-state* (sb-ext:seed-random-state 17)) (random-seed 17) bit operators ash left shift when 2nd argument positive logand logior logxor lognot arithmetic-shift left shift when 2nd argument positive bitwise-and bitwise-ior

§6 Human · 0%

bitwise-xor bitwise-not bit-shift-left bit-shift-right bit-and bit-or bit-xor bit-not lsh left shift when 2nd argument positive logand logior logxor lognot binary, octal, and hex literals #b101010 #o52 #x2a #b101010 #o52 #x2a radix (format nil "~7r" 42) strings common lisp racket clojure emacs lisp string test (stringp "foo") (string? "foo") (string? "foo") (stringp "foo") string literal "foo bar" "foo bar" "foo bar" "foo bar" newline in literal yes yes yes yes literal escapes \" \\ \t \n \r \" \\ \ooo \uhhhh \b \t \n \f \r \" \\ \ooo \uhhhh \b \t \n \f \r \" \\ \ooo \uhhhh \xh - \xhhhhhh \C-x \M-x constructor (string #\f #\o #\o) (string ?f ?o ?o) format string (format nil "~a: ~a ~,2f" "Foo" 7 13.457) (format "~a ~a ~a" "Foo" 7 13.457) (String/format "%s: %d %.2f" (to-array ["Foo" 7 13.457])) (format "%s: %d %.2f" "Foo" 7 13.457) format specifiers ~a any type, human readable ~s any time, read parseable ~% newline ~~ tilde ~c character ~,5f 5 digits right of decimal mark ~d decimal ~x hex ~o octal ~b binary ~a any type, human readable ~s any time, read parseable ~% newline ~~ tilde ~c character ~d decimal ~x hex ~o octal ~b binary compare strings (string= "foo" "bar") (string< "foo" "bar") (string=? "

§7 Human · 0%

foo" "bar") (string<? "foo" "bar") (.equals "foo" "bar") (.compareTo "foo" "bar") (string= "foo" "bar") (string< "foo" "bar") concatenate (concatenate 'string "foo " "bar " "bar") (string-append "foo " "bar " "baz") (str "foo " "bar " "baz") (concat "foo " "bar " "baz") replicate make-string 3 :initial-element #\f) (make-string 3 #\f) (String. (into-array (. Character TYPE) (repeat 3 \f))) (make-string 3 ?f) translate case (string-downcase "FOO") (string-upcase "foo") (string-downcase "FOO") (string-upcase "foo") (.toLowerCase "FOO") (downcase "FOO") (upcase "foo") capitalize ; "Foo Bar": (string-capitalize "foo bar") ; "Foo Bar": (capitalize "foo") trim (string-trim '(#\space #\tab #\newline) " foo ") (require srfi/13/string) (string-trim-both " foo ") (.trim " foo ") none; see notes for an implementation pad on right, on left (format nil "~10a" "foo") (format nil "~10@a" "foo") number to string (concatenate 'string "value: " (princ-to-string 8)) (string-append "value: " (number->string 8)) (str "Value: " 8) (concat "value: " (number-to-string 8)) string to number (+ 7 (parse-integer "12")) (+ 73.9 (read-from-string ".037")) (+ 7 (string->number "12")) (+ 73.9 (string->number ".037")) (+ 7 (Integer/parseInt "12")) (+ 73.9 (Float/parseFloat ".037")) (+ 7 (string-to-number "12")) (+ 73.9 (string-to-number ".037")) split (cl-ppcre:split "[ \t\n]+" "foo bar baz")

§8 Human · 0%

(regexp-split #rx"[ \n\t]+" "foo bar baz") (seq (.split "foo bar baz" "[ \t\n]+")) (split-string "foo bar baz") string join (reduce (lambda (m o) (concatenate 'string m " " o)) '("foo" "bar" "baz")) (string-join '("foo" "bar" "baz") " ") (reduce #(str %1 " " %2) '("foo" "bar" "baz")) (reduce (lambda (m o) (concat m " " o)) '("foo" "bar" "baz")) length (length "foo") (string-length "foo") (.length "foo") (length "foo") index of substring (search "bar" "foo bar") racket: (require srfi/13/string) (string-contains "foo bar" "bar") (.indexOf "foo bar" "bar") (search "bar" "foo bar") extract substring (subseq "foo bar" 4 7) (substring "foo bar" 4 7) (.substring "foo bar" 4 7) (substring "foo bar" 4 7) character literal #\a #\space #\newline #\backspace #\tab #\linefeed #\page #\return #\rubout #\a #\space #\newline #\backspace #\tab #\linefeed #\page #\return #\nul #\vtab #\alarm #\esc #\delete not in racket: #\alarm #\esc #\delete \a \newline \space \backspace \tab ? \formfeed \return ? ?a ?\b ?\t ?\n ?\f ?\r ?\" ?\\ ?\ooo ?\uhhhh ?\xh - ?\xhhhhhh ?\C-x ?\M-x test characters (characterp #\x) (alpha-char-p #\x) (alphanumericp #\x) (digit-char-p #\7) (lower-case-p #\x) (upper-case-p #\X) (char? #\x) (char? \x) (characterp ?