OCaml - Language extensions (original) (raw)

☰The OCaml language

Chapter 12 Language extensions

11 Syntax for Bigarray access

(Introduced in Objective Caml 3.00)

This extension provides syntactic sugar for getting and setting elements in the arrays provided by the Bigarray module.

The short expressions are translated into calls to functions of theBigarray module as described in the following table.

expression translation
expr0.{expr1} Bigarray.Array1.get expr0 expr1
expr0.{expr1} <-expr Bigarray.Array1.set expr0 expr1 expr
expr0.{expr1, expr2} Bigarray.Array2.get expr0 expr1 expr2
expr0.{expr1, expr2} <-expr Bigarray.Array2.set expr0 expr1 expr2 expr
expr0.{expr1, expr2, expr3} Bigarray.Array3.get expr0 expr1 expr2 expr3
expr0.{expr1, expr2, expr3} <-expr Bigarray.Array3.set expr0 expr1 expr2 expr3 expr
expr0.{expr1, …, exprn} Bigarray.Genarray.get expr0 [| expr1, … , exprn ]
expr0.{expr1, …, exprn} <-expr Bigarray.Genarray.set expr0 [| expr1, … , exprn ] expr

The last two entries are valid for any n > 3.

Copyright © 2025 Institut National de Recherche en Informatique et en Automatique