Iota函数

iota 函数是一个计算机语言中的函数,用于产生连续的值。

该函数得名自 APL 语言,其中用来产生从 1 开始的连续数值。

提供该函数的语言

APL

写作,产生从 1 到 N 的连续整数,即 1、2、3、……、N。

C++

C++11 起提供,位于 <numerics> 中。

#include <iostream>
#include <vector>
#include <numerics>

std::vector<char> vch(26);
std::iota(vch.begin(), vch.end(), 'a');
for(char ch: vch){
  std::cout<<ch;//abcdefghijklmnopqrstuvwxyz
}

.NET Framework

在 System.Linq.Enumerable(以及 ParallelEnumerable)中。

Dim vi As New List(Of Integer)(System.Linq.Enumerable.Range(5, 6))
For Each i As Integer In vi
  System.Diagnostics.Debug.WriteLine(i)'5 6 7 8 9 10
Next i
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.