979 B
979 B
| id | name | category | kind | tokens | sig | tip | order | ns | member |
|---|---|---|---|---|---|---|---|---|---|
| list-contains | List.contains | list | namespace-method | List.contains | List.contains(s, v) -> bool | Whether a value appears in a slice. | 7 | List | contains |
Scans s and returns true if any element equals v. Comparison is by value for scalar elements (ints, entities, booleans) and by identity for reference elements. Use it for membership tests — has this tile been visited, is this entity already in the target list, is the achievement unlocked. It is a linear scan, so for very large or hot-path sets a dedicated structure will be faster.
Parameters:
s— the slice to searchv— the value to look for
program Visited {
state VisitedState {
seen: []int = new []int
}
handler Step(visited_st: VisitedState) phase Update {
let tile = 42
if not List.contains(visited_st.seen, tile) {
List.push(visited_st.seen, tile)
}
}
}