Learn R Programming

parcr (version 0.5.1)

literal: Matching parser input with a literal string

Description

literal tests whether a supplied string literally equals a desired value.

Usage

literal(string)

Value

A parser.

Arguments

string

string, a single-element character vector, or an object that can be coerced to a character vector.

Pseudocode


literal(a)(x): satisfy(F(y): y==a)(x)

where F is equivalent to the function declarator in R. So, we have an anonymous function in the argument of satisfy.

Examples

Run this code
literal("ab") (c("ab", "cdef")) # success
literal("ab") (c("abc", "cdef")) # failure

Run the code above in your browser using DataLab