Compound data type: Difference between revisions
Content added Content deleted
(autohotkey example) |
(added Clojure version) |
||
Line 186: | Line 186: | ||
===Synonym type=== |
===Synonym type=== |
||
<lang clean>:: Point :== (Int, Int)</lang> |
<lang clean>:: Point :== (Int, Int)</lang> |
||
=={{header|Clojure}}== |
|||
<lang clojure>(defrecord Point [x y])</lang> |
|||
This defines a datatype with constructor ''Point.'' and accessors '':x'' and '':y'' : |
|||
<lang clojure>(def p (Point. 0 1)) |
|||
(assert (= 0 (:x p))) |
|||
(assert (= 1 (:y p)))</lang> |
|||