Compound data type: Difference between revisions

added Clojure version
(autohotkey example)
(added Clojure version)
Line 186:
===Synonym type===
<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>
 
 
Anonymous user