any() Function

Calls a rule or function that returns either true or false for each item in list by asking the question, "Do any items in this list yield true for this rule/function?" with the intent to discover if any item(s) yield true.

Syntax

any( predicate, list, [context, … ] )

predicate: (Function, Rule, or Data Type Constructor) Expression that returns a Boolean (true or false).

list: (Any Type Array) List of elements that the predicate iterates through.

context: (Any Type Array) Variable number of parameters passed directly into each predicate evaluation.

Returns

Boolean

Notes

Use fn!functionName to reference an expression function and rule!ruleName to reference a rule.

Returns true as soon as the returned value of an evaluation yields true; otherwise, returns false.

Empty and null lists yield false.

Serves as an alternative to or(apply(rule!iseven, {-1,0,1,2})).

a!forEach() cannot be used within rules used in this function.

Examples

Given a function f(x) , any(fn!f, {a, b, c}, v)) returns or({f(a, v), f(b, v), f(c, v)})

any(rule!iseven,{-1,0,1,2}) returns true

Open in Github Built: Thu, Feb 23, 2023 (02:59:22 PM)

On This Page

FEEDBACK