Support for list/array slicing?

57 views
Skip to first unread message

Chance Zibolski

unread,
Jun 22, 2023, 5:43:44 PM6/22/23
to CEL Go Discussion Forum
Is there any support for slicing lists/arrays? 

For example:

% let x= ['foo', 'bar', 'baz']
x[1:2]
['bar', 'baz']

So far I've checked, but can't seem to find any reference functionality like this in the language spec. If it's not possible with CEL directly, would it be possible to define a macro that supports slicing?

Chance Zibolski

unread,
Jun 22, 2023, 6:47:36 PM6/22/23
to CEL Go Discussion Forum
I managed to figure out how to implement it using a helper function in cel-go. Here's my code in case it helps anyone else: https://github.com/google/cel-go/compare/master...chancez:cel-go:pr/chancez/slice_function

Since https://github.com/google/cel-go/tree/master/ext seems to have a number of useful functions similar, I'll see if I can upstream it (and get some feedback on how to improve it).

Tristan Swadell

unread,
Jun 22, 2023, 7:37:43 PM6/22/23
to Chance Zibolski, CEL Go Discussion Forum
Hi Chance,

Feel free to submit a PR to the `ext` package and we can go from there.

Cheers,

-Tristan

--
You received this message because you are subscribed to the Google Groups "CEL Go Discussion Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cel-go-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cel-go-discuss/36934b97-db3b-44e4-abf9-0588b15d9642n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages