You can use Cue definitions or structs to create function like objects.
It is typical to have an input and output schema, and then you are free
to do whatever else you like in between them.
There is a proposal to simplify this pattern with official syntax.
See the beginning of the
core builtin extensions
for more details.
function.cue
packagefunctionimport"strings"// An input schema#Input: { count: int msg: string}// An output schema#Output: { val: string}#Transform: {// Input for the caller X1="in": #Input// output for the caller out: #Output// intermediate fields _upper: strings.ToUpper(X1.msg) _msg: strings.Join([_upper]*X1.count, " ")// set output out: val: _msg}// Call transformresult: #Transform & {in: {msg: "ra", count: 3}}