ludic/docs/language/list/list-len.md

768 B

id name category kind tokens sig tip order ns member
list-len List.len list namespace-method List.len List.len(s) -> int The number of elements in a slice. 0 List len

Returns how many elements s currently holds. It reads the slice's length, which changes as you List.push and List.pop, and is the same value as the bare len(s). Use it to bound a loop, test for emptiness, or find the last index with List.len(s) - 1.

Parameters:

  • s — the slice to measure
program CountEnemies {
  state CountEnemiesState {
    enemies: []int = new []int
  }

  handler Report(count_enemies_st: CountEnemiesState) phase Update {
    let n = List.len(count_enemies_st.enemies)
  }
}