The "Function" Pattern
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.