Loops/Foreach: Difference between revisions

Lingo added
(Lingo added)
Line 1,166:
Very good!
Fantastically good!
 
=={{header|Lingo}}==
 
<lang lingo>days = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]
repeat with day in days
put day
end repeat</lang>
A callback-based forEach() can be implemented like this:
<lang lingo>----------------------------------------
-- One of the five native iterative methods defined in ECMAScript 5
-- @param {list} tList
-- @param {symbol} cbFunc
-- @param {object} [cbObj=_movie]
----------------------------------------
on forEach (tList, cbFunc, cbObj)
if voidP(cbObj) then cbObj = _movie
cnt = tList.count
repeat with i = 1 to cnt
call(cbFunc, cbObj, tList[i], i, tList)
end repeat
end</lang>
<lang lingo>days = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]
forEach(days, #alert, _player)</lang>
 
=={{header|Lisaac}}==
Anonymous user