home > 比較編 > JavaScript, Lua, Io > execution control >

ForNext

Only Do What Only You Can Do

114. generator

JavaScript

none



















Lua

crt = coroutine.create(
  function (n)
    while (true) do
      coroutine.yield(n % 2)
      n = n + 1
    end
  end
)

status, retval =
  coroutine.resume(crt, 1)

if status then
  print("parity: " .. retval)
else
  print("couldn't resume crt")
end

_, retval = coroutine.resume(crt)
print("parity: " .. retval)

Io

none; although Io has coroutines, yield and resume do not pass values. Also, yield returns control to a scheduler, not the caller.



















VBScript

Perl

PHP

Python

Ruby

PowerShell

Scala

F#

C

C++

C++Builder

VC++

C#

Java

Objective-C

D

VB

VB.NET

Delphi

Ada

PL/SQL

T-SQL

関数型

inserted by FC2 system