博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Hy (lisp)
阅读量:7089 次
发布时间:2019-06-28

本文共 1315 字,大约阅读时间需要 4 分钟。

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

转载于:https://juejin.im/post/5c4f04c8e51d4551c8805ef2

你可能感兴趣的文章
JSP中的EL语言
查看>>
飞秋命令行
查看>>
mongodb
查看>>
高性能通道
查看>>
做题时一时没想起来的问题总结
查看>>
设计模式笔记--策略
查看>>
Eight(经典题,八数码)
查看>>
Balala Power!(大数+思维)
查看>>
[转]python-元类
查看>>
Django 模型 - 模型的定义
查看>>
复习日记-Listener/filter/servlet3.0/动态代理
查看>>
定时任务框架APScheduler学习详解
查看>>
vue中Axios的封装和API接口的管理
查看>>
Win7x64安装了DroidPilot-Win64.exe之后跑不起来 -- 解决办法
查看>>
VS2010 中C++ 和C# 颜色转化
查看>>
idea 新手入门配置
查看>>
JAVA 通过 JACOB 调用 WMI
查看>>
构建工具系列一--Travis-cli
查看>>
日历时间选择控件---3(支持ie、火狐)
查看>>
电梯设计大作业——概要设计
查看>>