libs icon indicating copy to clipboard operation
libs copied to clipboard

New transformer: `len()`

Open leogr opened this issue 1 year ago • 1 comments

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.

leogr avatar Oct 22 '24 08:10 leogr

/milestone 0.19.0

FedeDP avatar Oct 23 '24 15:10 FedeDP