New .%() operators

Quoting @art-w in a previous post about syntactical sugar:

The new .%() operators aren’t really popular. It takes a lot of time and motivation to introduce new syntax.

I’m embarrased to say I couldn’t find any information on these operators. Does anyone have a good blog or documentation on them?

Thanks!

3 Likes

https://ocaml.org/manual/indexops.html

Cheers,
Nicolas

7 Likes

Owl is one of the main user of those operators (which is expected since they were introduced with numerical libraries in mind) in particular to get a lighter syntax for slicing: Slicing and Broadcasting - Owl Online Tutorials .
For instance, the linked tutorial provides an example for zeroing a slice of an array:

let x = sequential [|10; 10; 10|] in
let a = x.${[0;4]; [6;-1]; [-1;0]} in
let b = zeros (shape a) in
x.${[0;4]; [6;-1]; [-1;0]} <- b 
7 Likes