← Back to Table of Contents

Appendix A: Complete Operator Reference

This appendix provides a quick reference for all 40 operators available in Computo.

Data Access & Scoping


let

Binds variables to expressions for use within a scoped body.


$

Retrieves the value of a variable defined by let.


get

Retrieves a value from a JSON object or array using a JSON Pointer.


$input

Returns the entire input JSON document that was provided to the script (equivalent to the first input when multiple inputs are provided).


$inputs

Returns an array containing all input JSON documents that were provided to the script.

Logic & Control Flow


if

Evaluates a condition and returns one of two expressions.


&&

Logical AND operator with short-circuit evaluation. Returns true only if all arguments are truthy.


||

Logical OR operator with short-circuit evaluation. Returns true if any argument is truthy.


not

Logical NOT operator that negates the truthiness of its argument.


==, !=, >, <, >=, <=

Perform a comparison between two values. Math comparisons require numbers.


approx

Checks if two numbers are approximately equal within a given epsilon.

Data Construction & Manipulation


obj

Creates a JSON object from key-value pairs.


merge

Merges two or more objects. Rightmost keys win in case of conflict.


permuto.apply

Applies a Permuto template to a context object.

String Operations


str_concat

Concatenates multiple strings into a single string. Automatically converts non-string values to strings.

JSON Patch Operations (RFC 6902)


diff

Generates an RFC 6902 JSON Patch array that describes the differences between two JSON documents.


patch

Applies an RFC 6902 JSON Patch array to a document, returning the modified document.

Mathematical


+, -, *, /, %

Performs a mathematical operation on two numbers.


%

Calculates the remainder (modulo) when dividing two numbers.

Lambda Functions


lambda

Defines an anonymous function for use with array operators. Used ONLY with array operators (map, filter, reduce, find, some, every, flatMap).

Array Operators

Note: For all array operators, literal arrays must be specified using {"array": [...]} syntax.


map

Applies a lambda to each item in an array, returning a new array of transformed items.


filter

Returns a new array containing only items for which the lambda returns a truthy value.


reduce

Reduces an array to a single value by applying a two-argument lambda.


find

Returns the first item in an array for which the lambda returns a truthy value, or null if no match is found.


some

Returns true if the lambda returns a truthy value for at least one item in the array, false otherwise.


every

Returns true if the lambda returns a truthy value for all items in the array, true for an empty array, false otherwise.


flatMap

Like map, but if a lambda returns an array, its items are flattened into the result array.


count

Returns the number of items in an array.


zip

Combines two arrays element-wise into an array of pairs.


zipWith

Combines two arrays element-wise using a custom function.


mapWithIndex

Maps over an array with access to both element and its index position.


enumerate

Transforms an array into [index, value] pairs.

List Processing (Functional)


car

Returns the first element of an array. Inspired by Lisp's car function.


cdr

Returns all elements except the first from an array. Inspired by Lisp's cdr function.


cons

Prepends an item to the beginning of an array. Fundamental list building operation from functional programming.


append

Concatenates multiple arrays into a single array.


chunk

Splits an array into smaller arrays of a specified size. Perfect for batch processing.


partition

Splits an array into two groups based on a predicate function: [truthy_items, falsy_items].

← Back to Table of Contents