findall {rolog}R Documentation

Invoke a query several times

Description

Invoke a query several times

Usage

findall(
  query = call("member", expression(X), list(quote(a), "b", 3L, 4, TRUE, expression(Y))),
  options = list(portray = FALSE),
  env = globalenv()
)

Arguments

query

an R call. The R call consists of symbols, integers and real numbers, character strings, boolean values, expressions, lists, and other calls. Vectors of booleans, integers, floating point numbers, and strings with length N > 1 are translated to prolog compounds !/N, %/N, #/N and $$/N, respectively. The names can be modified with the options below.

options

This is a list of options controlling translation from and to prolog.

  • boolvec (see option rolog.boolvec, default is !) is the name of the prolog compound for vectors of booleans.

  • intvec, realvec, charvec define the compound names for vectors of integers, doubles and strings, respectively (defaults are %, # and $$).

  • If scalar is TRUE (default), vectors of length 1 are translated to scalar prolog elements. If scalar is FALSE, vectors of length 1 are also translated to compounds.

env

The R environment in which the query is run (default: globalenv()). This is mostly relevant for r_eval/2.

Value

If the query fails, an empty list is returned. If the query succeeds N >= 1 times, a list of length N is returned, each element being a list of conditions for each solution, see once().

See Also

once() for a single query

query(), submit(), and clear() for fine-grained control over non-deterministic queries

rolog_options()

Examples

# This query returns a list stating that it works if X = a, "b", ...
findall(call("member", expression(X), list(quote(a), "b", 3L, 4, TRUE, NULL, NA)))

# Continued
findall(call("member", expression(X), list(call("sin", call("/", quote(pi), 2)), expression(Y))))

# The same using simplified syntax
q <- quote(member(.X, ""[a, "b", 3L, 4, TRUE, NULL, NA, sin(pi/2), .Y]))
findall(as.rolog(q))


[Package rolog version 0.9.17 Index]