Builtins内置函数
- type(): 查看对象类型
- id(): 查看对象id
- print(): 打印对象
- isNull(): 判断对象是否有效
- len(): 列表或字符串长度
- delete(): 删除对象
- globals(): 全局空间
locals(): 本地空间
first()
- last()
- rest()
- push()
- fibonacci()
type()
>> type([1,2])
"LIST"
>> type(type)
"BUILTIN"
id()
>> let name = 'Ledge'
"Ledge"
>> type(name)
"STRING"
>> id(name)
105553160290392
print()
>> print("Hello", "Ledge")
"Hello"
"Ledge"
null
isNull()
>> isNull([1,2,3][1])
false
>> isNull([1,2,3][3])
true
len()
>> len("hello")
5
>> len([1,2,3])
3
>> len("你好")
2
delete()
>> let a = 5
5
>> a
5
>> delete(a)
>> a
Woops! Compilation failed:
ERROR: undefined variable a
globals()
>> let a = [1,2]; let b=3.14; let c = {1:2}
{1: 2}
>> globals()
{"a": [1, 2], "b": 3.140000, "c": {1: 2}}
locals()
>> let a = [1,2]; let b=3.14; let c = {1:2}
{1: 2}
>> globals()
{"a": [1, 2], "b": 3.140000, "c": {1: 2}}
>> locals()
{"a": [1, 2], "b": 3.140000, "c": {1: 2}}
>> def test(){ let a = 100; locals()}
Closure[0x600001658978]
>> test()
{"a": 100}
>> globals()
{"a": [1, 2], "b": 3.140000, "test": Closure[0x600001658978], "c": {1: 2}}
first()
>> first([1,2,3])
1
last()
>> last([1,2,3])
3
rest()
>> rest([1,2,3])
[2, 3]
push()
>> push([1,2,3], 4)
[1, 2, 3, 4]
fibonacci()
>> fibonacci(35)
9227465