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
123008907 abc123复制代码
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 etcData 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)复制代码