Skip to contents

Expand a sequence

Usage

# S4 method for sfc_rules,sfc_nxn
sfc_expand_by_rules(p, seq, code = 1L, flip = FALSE, by = "Cpp")

# S4 method for sfc_rules,factor
sfc_expand_by_rules(p, seq, code = 1L, flip = FALSE, by = "Cpp")

# S4 method for sfc_rules,character
sfc_expand_by_rules(p, seq, code = 1L, flip = FALSE, by = "Cpp")

Arguments

p

An sfc_rules object.

seq

An sfc_nxn object or other objects.

code

The expansion code.

flip

For the Peano curve and the Meander curves, each unit can be flipped without affecting other parts in the curve. This argument controls whether to flip the unit. Since currently it only works on the Peano curve and the Meander curve, flip should be a logical vector of length one or with the same length as seq. Whether it flips horizontally, vertically or against the diagonal line is automatically choosen. The value of flip can also be a function which takes the current curve as the only argument.

by

Which implementation? Only for the testing purpose.

Value

If seq is an sfc_nxn object, the function also returns an "expanded" sfc_nxn object. Or else it returns an sfc_sequence object.

Examples

sfc_expand_by_rules(SFC_RULES_2x2, sfc_2x2("I"))
#> An sfc_2x2 object.
#>   Increase mode: 2 x 2
#>   Level: 1
#>   Expansion rule: 2x2 
#> 
#> A sequence of 4 base patterns.
#>   R(0)L(270)L(0)R(90)  
#> 
#> Seed: A sequence of 1 base pattern.
#>   I(0)