Skip to content

New transformer: len() #2127

@leogr

Description

@leogr

Motivation

While discussing the intersect operator with @jasondellaluce, we realized there's no easy way to check for an empty list or, more generally, to know a list length.

It would be beneficial when one needs to create an exception, for example:
len(class.somelist) > 0 and not class.somelist intersect (allowlist)

(n.b. not class.somelist intersect (allowlist) is true when class.somelist is an empty list)

Furthermore, there may be compelling use cases where knowing the length of a list or a string is useful.

Feature

Develop a len() transformer that accepts a sizable type (e.g., LIST, CHARBUF, BYTEBUF) as input and returns its length as an integer.

Alternatives

No actual alternatives have been considered yet.

Additional context

This is a very rough proposal, which may need some discussion. Feedback is welcome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions