RobinHankin / freegroup

The free group in R
0 stars 0 forks source link

is.id() should be generic #12

Closed RobinHankin closed 6 years ago

RobinHankin commented 6 years ago

Function is.id() is currently just x == as.free(0) but it really should be generic.

Specifically:

> library(freegroup)
[snip]
> library(permutations)

Attaching package: ‘permutations’

The following objects are masked from ‘package:freegroup’:

    inverse, is.id

The following object is masked from ‘package:stats’:

    cycle

> is.id(rfree(10,3))
Error in UseMethod("is.id", x) : 
  no applicable method for 'is.id' applied to an object of class "free"
> 

Here, R is trying to use permutations::is.id() which is generic, but not finding a method. I am not sure why attaching the permutations package gives a warning about inverse() being masked, when it (apparently) works as intended:

> inverse(rfree(10,3))
 [1] a^3.c^-1.a     c^5.b          a^3.b^-3       b              b             
 [6] c^-1.b^-2.c^-2 0              c^-3.b^2.a^2   c^2            b.c^6         
> inverse(rperm(10,3))
 [1] ()    ()    ()    ()    (23)  (23)  (23)  (132) ()    (23) 
> 
RobinHankin commented 6 years ago

The link in the permutations repo is: RobinHankin/permutations#2