/ˌlɪŋɡwə ˈfraŋkə/
noun
A language that is adopted as a common language between speakers whose native languages are different.
“a problem well put is half solved.” John Dewey
“When concepts are integrated into a wider one, the new concept includes all the characteristics of its constituent units; but their distinguishing characteristics are regarded as omitted measurements, and one of their common characteristics determines the distinguishing characteristic of the new concept: the one representing their ‘Conceptual Common Denominator’ with the existents from which they are being differentiated.” Ayn Rand (ItOE)
PROGRAM = (WHITESPACE | COMMENT | APPLICATION)*
APPLICATION = "(" (WHITESPACE | ATOM | LIST | APPLICATION)* ")"
<ATOM> = SYMBOL
(* <ATOM> = BOOLEAN | NUMBER | STRING | SYMBOL *)
(* BOOLEAN = "True" | "False" *)
COMMENT = #";;\p{Blank}*" #"[^\s]?[^\n]*" "\n"
LIST = "[" (WHITESPACE | ATOM | LIST | APPLICATION)* "]"
(* NUMBER = #"-?\d+(\.\d+)?" *)
(* STRING = (<"\""> #"[^\"]* <"\"">) | (<"'"> #"[^']* <"'">) *)
SYMBOL = #"\w[\w\d-]*"
WHITESPACE = #"\s+"
Inspiration: Haskell vs. Ada vs. C++ vs. Awk vs. ... An Experiment in Software Prototyping Productivity
(inside? some-shape some-point) ;; => true | false
(point x y) ;; x & y are coordinates
circle ;; unit circle centered at the origin
;; All functions return a new shape
(translate shape dx dy)
(scale shape factor)
(union a b ...)
(intersection a b ...)
This is an embedded DSL.
(defn point [x y] (->Point x y))
(def origin (point 0 0))
(def circle (->Circle origin 1))
(defprotocol Shape
(inside? [this other])
(scale [this s])
(translate [this dx dy]))
(defrecord Point [x y]
Shape
(inside? [this other]
(and (instance? Point other)
(= this other)))
(scale [_ s]
(->Point (* x s)
(* y s)))
(translate [_ dx dy]
(->Point (+ x dx)
(+ y dy))))
;; Define a circle centered at (4, 3) with a radius of 5
(def some-circle
(-> circle
(scale 5)
(translate 4 3)
;; origin must be inside this shape
(inside? some-circle origin) ;; => true
(->Point x y) ;; concrete, Point record
vs.
(point x y) ;; abstract shape
(def list-and-an-item
(gen/bind (gen/not-empty (gen/vector gen/byte))
(fn [xs] (gen/tuple (gen/elements xs)
(gen/return xs)))))
vs.
(def list-and-an-item-2
(gen/let [xs (gen/not-empty (gen/vector gen/byte))
elem (gen/elements xs)]
[elem xs]))