Skip to content

Latest commit

 

History

History
33 lines (23 loc) · 704 Bytes

File metadata and controls

33 lines (23 loc) · 704 Bytes
layout language permalink command alias
api-command
Python
api/python/offsets_of/
offsets_of
api/python/indexes_of/

Command syntax

{% apibody %} sequence.offsets_of(datum | predicate_function) → array {% endapibody %}

Description

Get the indexes of an element in a sequence. If the argument is a predicate, get the indexes of all elements matching it.

Example: Find the position of the letter 'c'.

r.expr(['a','b','c']).offsets_of('c').run(conn)

Example: Find the popularity ranking of invisible heroes.

r.table('marvel').union(r.table('dc')).order_by('popularity').offsets_of(
    r.row['superpowers'].contains('invisibility')
).run(conn)