New doc system done for core
[io.git] / libs / iovm / io / Map.io
blob80ca8fa4b7f033713e5a4152b69241cf9dfdfd28
1 Map do(
2 //doc Map asList Converts a Map to a list of lists. Each element in the returned list will be a list of two elements: the key, and the value.
3 asList := method(
4 l := list
5 foreach(k, v, l append(list(k, v)))
9 map := method(
10 result := List clone
11 key := call argAt(0)
12 value := call argAt(1)
13 body := call argAt(2)
14 self foreach(k, v,
15 call sender setSlot(key name, k)
16 call sender setSlot(value name, v)
17 ss := stopStatus(r := call sender doMessage(body))
18 if(ss isReturn, call setStopStatus(ss); return getSlot("v"))
19 if(ss isBreak, break)
20 if(ss isContinue, continue)
21 result append(getSlot("r"))
23 result
27 select := method(
28 result := Map clone
29 self keys foreach(key,
30 if(call argCount > 1,
31 call sender setSlot(call argAt(0) name, key)
32 if(call argCount == 3,
33 call sender setSlot(call argAt(1) name, self at(key))
36 ss := stopStatus(v := call evalArgAt(call argCount - 1))
37 if(ss isReturn, call setStopStatus(ss); return getSlot("v"))
38 if(ss isBreak, break)
39 if(ss isContinue, continue)
40 if(getSlot("v"),
41 result atPut(key, self at(key))
44 result
47 detect := method(
48 self keys foreach(key,
49 if(call argCount > 1,
50 call sender setSlot(call argAt(0) name, key)
51 if(call argCount == 3,
52 call sender setSlot(call argAt(1) name, self at(key))
55 ss := stopStatus(v := call evalArgAt(call argCount - 1))
56 if(ss isReturn, call setStopStatus(ss); return getSlot("v"))
57 if(ss isBreak, break)
58 if(ss isContinue, continue)
59 if(getSlot("v"),
60 return list(key, self at(key))
65 reverseMap := method(
66 Map clone addKeysAndValues(values, keys)
69 asObject := method(
70 o := Object clone
71 self foreach(k, v, o setSlot(k, getSlot("v")))