mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-12-01 01:25:27 +01:00
create package from existing code
This commit is contained in:
parent
66e82e5bda
commit
35509a8304
22
src/free_groups.jl
Normal file
22
src/free_groups.jl
Normal file
@ -0,0 +1,22 @@
|
||||
import Base:convert
|
||||
|
||||
export FGSymbol, FGWord
|
||||
|
||||
immutable FGSymbol <: GSymbol
|
||||
gen::String
|
||||
pow::Int
|
||||
end
|
||||
|
||||
(==)(s::FGSymbol, t::FGSymbol) = s.gen == t.gen && s.pow == t.pow
|
||||
hash(s::FGSymbol, h::UInt) = hash(s.gen, hash(s.pow, hash(:FGSymbol, h)))
|
||||
|
||||
IdSymbol(::Type{FGSymbol}) = FGSymbol("(id)", 0)
|
||||
FGSymbol(x::String) = FGSymbol(x,1)
|
||||
|
||||
inv(s::FGSymbol) = FGSymbol(s.gen, -s.pow)
|
||||
convert(::Type{FGSymbol}, x::String) = FGSymbol(x)
|
||||
change_pow(s::FGSymbol, n::Int) = (n==0 ? i=one(s) : FGSymbol(s.gen, n))
|
||||
|
||||
typealias FGWord GWord{FGSymbol}
|
||||
|
||||
FGWord(s::FGSymbol) = FGWord([s])
|
Loading…
Reference in New Issue
Block a user