Messing around with lambda functions.

This commit is contained in:
Martin Haye 2017-08-10 07:31:31 -07:00
parent 0f8dbaba4a
commit 8c46ccc34d
2 changed files with 11 additions and 7 deletions

View File

@ -58,15 +58,19 @@ word = @_displayItemStats, @_displayItemName
// Other global variables here
def travFind2(pObj, val, func)
word ret
while pObj
val, ret = func(val, pObj)#2
if ret; return pObj; fin
pObj = pObj=>p_nextObj
loop
return NULL
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def itemByNum(player, num)#1
word item
item = player=>p_items
while num
item = item=>p_nextObj
num--
loop
return item
return travFind2(player=>p_items, num, &(n,p)(n-1, n==0))
end
///////////////////////////////////////////////////////////////////////////////////////////////////