head.logician_iterator: Return the first n results from an iterator

Description Usage Arguments Value Examples

View source: R/query.R

Description

Return the first n results from an iterator

Usage

1
2
## S3 method for class 'logician_iterator'
head(x, n = 6, ...)

Arguments

x

an object

n

an length 1 integer >= 1. sometimes that can result in an infinite loop

...

unused dots

Value

For each solution a list of substitions.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
database <- logician_database(
  connected(berlin, hamburg),
  connected(hamburg, chicago),
  connected(chicago, london),
  connected(aachen, berlin),
  connected(chicago, portland),
  connected(portland, munich),
  path(A, B) := connected(A, B),
  path(A, B) := connected(A, Z) && path(Z, B)
)
iter <- logician_query(database, path(berlin, X))
head(iter, 4) # get the first 4 results if they exists

dirkschumacher/logician documentation built on June 13, 2020, 5:11 p.m.