当前位置:网站首页>Lua有状态迭代器
Lua有状态迭代器
2022-07-27 07:42:00 【nginx】
#!/usr/bin/luaprint("haicoder()\n")array = {"Hello", "HaiCoder", "Lua"}function elementIterator (collection)local index = 0local count = #collection-- 闭包函数return function ()index = index + 1if index <= countthen-- 返回迭代器的当前元素return collection[index]endendendfor element in elementIterator(array)doprint(string.format("Element = %s", element))end
边栏推荐
- Temperature and humidity measurement and display device based on Arduino
- 【pytorch】ResNet18、ResNet20、ResNet34、ResNet50网络结构与实现
- 一体化实时HTAP数据库StoneDB,如何替换MySQL并实现近百倍分析性能的提升
- C language implementation of guessing numbers Games project practice (based on srand function, rand function, switch statement, while loop, if condition criterion, etc.)
- Confluence vulnerability learning - cve-2021-26084/85, cve-2022-26134 vulnerability recurrence
- Docker install MySQL 8.0.28
- Multi condition query of when
- IDEA中文乱码怎么办
- A priority SQL problem
- Do me a favor ~ don't pay attention, don't log in, a questionnaire in less than a minute
猜你喜欢

ADC噪声全面分析 -02- ADC 噪声测量方法和相关参数

帮个忙呗~不关注不登录,不到一分钟的一个问卷

SQLite common function integration

OpenGL shader learning notes: varying variables

Install tensorflow

【已解决】新版Pycharm(2022)连接服务器进行上传文件报错“Command rsync is not found in PATH”,无法同步文件

10000 word parsing MySQL index principle -- InnoDB index structure and reading

STM32_ Find the cause of entering hardfault_ Handler's function

将对象转换为键值对

Demo submit a program and obtain ALV data of the program
随机推荐
LeetCode56. 合并区间
MySQL table name area in Linux is not case sensitive
C# 中的转译字符'/b'
单片机多级菜单
JS存取cookie示例
What other methods are available for MySQL index analysis besides explain
shell循环练习
The DrawImage method calls the solution of not displaying pictures for the first time
Demo submit a program and obtain ALV data of the program
Error when connecting to MySQL: public key retrieval is not allowed [solution]
Leetcode54. 螺旋矩阵
Regular and sed exercises
opengl-shader学习笔记:varying变量
Help send a recruitment, base all over the country. If you are interested, you can come and have a look
什么是真正的HTAP?(一)背景篇
Installation and use of apifox
记录一个自己挖的坑~
基于Arduino的温度、湿度测量显示装置
API 版本控制【 Eolink 翻译】
ADC噪声全面分析 -02- ADC 噪声测量方法和相关参数