Skip to content

← programming package

ListFind

Find the first (or last) index at which a specific item is found.

The item may also be identified by means of a predicate (function/graph). If the item is not found, return the value specified by the 'notfound' port (default -1). If the list is None, None is propagated out. Version 1.0.0

Ports/Properties

lst

List to process.

  • verbose name: Lst
  • default value: None
  • port type: DataPort
  • value type: list (can be None)
  • data direction: IN

item

Item whose index to return.

  • verbose name: Item
  • default value: None
  • port type: DataPort
  • value type: object (can be None)
  • data direction: IN

pred

Predicate to use to find the item.

  • verbose name: Pred
  • default value: None
  • port type: GraphPort
  • value type: Graph

pred__signature

Optional name of a placeholder that will receive the list element of which to compute the find predicate. Instead of searching for an item by value, you can specify a predicate function. The predicate, if specified, is a function that returns True if the current item is the one that is being searched, and False otherwise. You can define a predicate function by creating a graph that starts with a Placeholder node whose slotname must be set to the same name as listed here (e.g., "item"), followed by some computation, and whose final node returns True or False. That final node's output is then wired into the "pred" input port of ListFind. In graphical UIs this edge will show as dotted to indicate that this is not normal forward data flow but a subgraph (i.e., the predicate) being passed to the List Find node. The predicate function is then called for each element in the list, and upon encountering an item where the predicate returns True, the search terminates and returns the item in question. If the predicate is not specified, ListFind by default compares with the value in the "item" port. This graph should only involve stateless nodes.

  • verbose name: Pred [Optional Find Predicate Argument]
  • default value: (item)
  • port type: Port
  • value type: object (can be None)

index

Index of item in list.

  • verbose name: Index
  • default value: None
  • port type: DataPort
  • value type: int (can be None)
  • data direction: OUT

find_last

Find the index of the last occurrence instead of the first.

  • verbose name: Find Last
  • default value: False
  • port type: BoolPort
  • value type: bool (can be None)

notfound

Value to return if the item is not found. This can also be set to None if desired.

  • verbose name: If Not Found
  • default value: -1
  • port type: IntPort
  • value type: int (can be None)

set_breakpoint

Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.

  • verbose name: Set Breakpoint (Debug Only)
  • default value: False
  • port type: BoolPort
  • value type: bool (can be None)

metadata

User-definable meta-data associated with the node. Usually reserved for technical purposes.

  • verbose name: Metadata
  • default value: {}
  • port type: DictPort
  • value type: dict (can be None)