obsidian-notes/代码/数组.md
CSSC-WORK\murmur 3e6078442b init version
2024-04-15 11:19:57 +08:00

26 lines
474 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: 数组
updated: 2022-03-15 07:59:11Z
created: 2022-03-15 07:44:09Z
---
## 提取数组的key
这个并不比直接用`for in` 快map内部就是用的`for in`。
```js
var str = {}
table.map(num,lambda(v,k,r) table.push(str,v) )
```
## 更改数组的元素
```js
var num1 = table.map(num,lambda(v,k) tonumber(v) )
```
## 交换数组的key和value
可同时处理数组元素
```js
var newt=table.map(t,function(v,k,result){
result[tonumber(v)]=k
})
```