Without using an intermediate name, you cannot access the receiver inside the map. The map is evaluated within the context of the caller, i.e., where your call to list(1,2,3,4)
would be made.
How do I refer to the list being mapped in Io?
-
22-03-2022 - |
문제
Io allows an optional parameter referring to the index of a list item. How do I use that to refer to the list being mapped, for example, I could write:
testList := list(1,2,3,4)
testList map(i,v, if(testList(i+v), v, v-1))
and the result would be list(1,2,3,3)
But what if I want to write that without creating the variable testList? How do I refer to the list that I'm mapping?
해결책
제휴하지 않습니다 StackOverflow