1958 (Lisp) -> 2020 (Hy)
Hy designed to interact with Python by translating expressions into Python's abstract syntax tree (AST)
(write-line "Hello World") (write (+ 7 9 11)) # 7 + 9 + 11 (write (+ (* (/ 9 5) 60) 32)) # ((9/5)*60)+32
basic building blocks
atom: numbers and special characters
list: a sequence of atoms and/or other lists enclosed in parentheses
(a ( a b c) d e fgh)
string: a group of characters enclosed in double quotation marks
" I am a string"
semicolon symbol (;) is used for indicating a comment line case-insensitive three types of elements are constants and always return their own value Numbers; letter t, logical true; value nil, logical false, empty list
data types can be categorized as
Scalar types - for example, number types, characters, symbols etc
Data structures - for example, lists, vectors, bit-vectors, and strings
macro is a function
(defmacro setTo10(num) (setq num 10)(print num)) (setq x 25) (print x) (setTo10 x)
Global variables are generally declared using the defvar construct.
(defvar x 234) (write x)
let and prog for creating local variables.
(prog ((x '(a b c))(y '(1 2 3))(z '(p q 10))) (format t "x = ~a y = ~a z = ~a" x y z)) # x = (A B C) y = (1 2 3) z = (P Q 10)