# Experimental package Gapjm.jl porting some GAP functionality to Julia

**URL:** <https://discourse.julialang.org/t/experimental-package-gapjm-jl-porting-some-gap-functionality-to-julia/16002>\
**Category:** Community\
**Created:** [October 7, 2018, 9:34pm UTC](https://discourse.julialang.org/t/experimental-package-gapjm-jl-porting-some-gap-functionality-to-julia/16002 "2018-10-07T21:34:25Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jean\_Michel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jean_michel/32/8282_2.png) [@Jean\_Michel](https://discourse.julialang.org/u/Jean_Michel)\
**Post date:** [October 7, 2018, 9:34pm UTC](https://discourse.julialang.org/t/experimental-package-gapjm-jl-porting-some-gap-functionality-to-julia/16002/1 "2018-10-07T21:34:25Z")

</div>

I put on  
`github.com/jmichel7/Gapjm.jl`

my first efforts porting some functionality provided by the GAP programming language to Julia.  
What I have now is permutations and permutation groups, cyclotomic numbers and Laurent polynomials. Coming soon are Coxeter groups, Hecke algebras, braid groups and Garside monoids.

I learned both Julia and github just a few months ago, so be indulgent – though I welcome all kinds of constructive criticsm: I not even sure what I put up is a proper Julia package, since I had trouble finding an  
explanation step by step how to make a package aimed at a beginner like me.

I wanted to see if it is reasonable to think of porting a system like GAP to Julia. The first test is positive: similar functionality and performance with much less code when porting the underlying C code, and even a bit less  
code when porting the GAP code. However one piece is missing: in GAP there is only one kind of numbers, which starting as Int64 seamlessly become BigInt, Rationals or Cyclotomics, and are very efficient (with the trick that a bit is set apart in Int64s to tell if it is a real Int or a boxed value). It should be possible to write such a type in Julia but it has not been done (and it is out of my competence for the near future at least). For now a solution like SafeIntegers might be the best which exists.  
To give some perspective, in some tests I made BigInts used for a computation where most Ints are “small”  
and only a few overflow is 200 times slower than GAP numbers (while SafeIntegers are roughly the same speed).

---

<div class="post-metadata">

**Author:** ![tlienart](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tlienart/32/7640_2.png) [@tlienart](https://discourse.julialang.org/u/tlienart)\
**Post date:** [October 7, 2018, 10:39pm UTC](https://discourse.julialang.org/t/experimental-package-gapjm-jl-porting-some-gap-functionality-to-julia/16002/2 "2018-10-07T22:39:41Z")

</div>

A quick look at your `Gapjm.jl` file:

```julia
push!(LOAD_PATH, @ __DIR__ ) # not sure if this is the right way to use modules

```

is not needed, see [this part of the Pkg doc](https://julialang.github.io/Pkg.jl/latest/managing-packages.html#Developing-packages-1), basically you should do something like follows in your REPL

```julia
] # enter package mode
dev https://github.com/jmichel7/Gapjm.jl

```

Also

- there are no tests?
- would it not be simpler to find if it was just called `GAP.jl`?

---

<div class="post-metadata">

**Author:** ![Jean\_Michel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jean_michel/32/8282_2.png) [@Jean\_Michel](https://discourse.julialang.org/u/Jean_Michel)\
**Post date:** [October 7, 2018, 10:47pm UTC](https://discourse.julialang.org/t/experimental-package-gapjm-jl-porting-some-gap-functionality-to-julia/16002/3 "2018-10-07T22:47:38Z")

</div>

Your pointer to Pkg doc does not work. I needed to extend LOAD\_PATH otherwise the submodules Perms, etc in my package are not found.

I wanted to put first as tests what appears as `julia-repl` in my docstrings, however I could not see how to make Documenter.jl do that: it wants rather what appears as ‘`jldoctest`’. Is there a way to use the examples in my docstrings as tests?

Finally I called my package Gapjm and not Gap because I know some other people may be working on Gap-related packages.

---

<div class="post-metadata">

**Author:** ![abulak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abulak/32/28314_2.png) [@abulak](https://discourse.julialang.org/u/abulak)\
**Post date:** [October 7, 2018, 11:05pm UTC](https://discourse.julialang.org/t/experimental-package-gapjm-jl-porting-some-gap-functionality-to-julia/16002/4 "2018-10-07T23:05:25Z")

</div>

how about `include`ing all the files instead of extending `LOAD_PATH`?

`jldoctest`s appear in the documentation exactly as `julia-repl` but are run only when the documentation is build

---

<div class="post-metadata">

**Author:** ![tlienart](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tlienart/32/7640_2.png) [@tlienart](https://discourse.julialang.org/u/tlienart)\
**Post date:** [October 7, 2018, 11:23pm UTC](https://discourse.julialang.org/t/experimental-package-gapjm-jl-porting-some-gap-functionality-to-julia/16002/5 "2018-10-07T23:23:11Z")

</div>

(link fixed, apologies, you may also want to consider [Modules · The Julia Language](https://docs.julialang.org/en/v1.0/manual/modules/#Relative-and-absolute-module-paths-1) as per issue posted on your repo)

---

<div class="post-metadata">

**Author:** ![Jean\_Michel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jean_michel/32/8282_2.png) [@Jean\_Michel](https://discourse.julialang.org/u/Jean_Michel)\
**Post date:** [October 7, 2018, 11:32pm UTC](https://discourse.julialang.org/t/experimental-package-gapjm-jl-porting-some-gap-functionality-to-julia/16002/6 "2018-10-07T23:32:08Z")

</div>

What I would like is for a `runtests.jl` to be made automatically from the` julia-repl` in my docstrings. Is there something which can do that?

---

<div class="post-metadata">

**Author:** ![Jean\_Michel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jean_michel/32/8282_2.png) [@Jean\_Michel](https://discourse.julialang.org/u/Jean_Michel)\
**Post date:** [October 7, 2018, 11:35pm UTC](https://discourse.julialang.org/t/experimental-package-gapjm-jl-porting-some-gap-functionality-to-julia/16002/7 "2018-10-07T23:35:47Z")

</div>

Can you show me how would look the file `Gapjm.jl`? I did not manage to write something which works without error.

And same question to @tlienart

---

<div class="post-metadata">

**Author:** ![tlienart](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tlienart/32/7640_2.png) [@tlienart](https://discourse.julialang.org/u/tlienart)\
**Post date:** [October 7, 2018, 11:50pm UTC](https://discourse.julialang.org/t/experimental-package-gapjm-jl-porting-some-gap-functionality-to-julia/16002/8 "2018-10-07T23:50:01Z")

</div>

@Jean_Michel for the paths, please see [https://github.com/jmichel7/Gapjm.jl/issues/2](https://github.com/jmichel7/Gapjm.jl/issues/2). Note the use of `using .Util` in `Gapjm.jl` and `using ..Util` in `Perms.jl` for instance.

---

<div class="post-metadata">

**Author:** ![abulak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abulak/32/28314_2.png) [@abulak](https://discourse.julialang.org/u/abulak)\
**Post date:** [October 8, 2018, 12:28am UTC](https://discourse.julialang.org/t/experimental-package-gapjm-jl-porting-some-gap-functionality-to-julia/16002/9 "2018-10-08T00:28:55Z")

</div>

first You need to fix Your deps;

then use `include("Util.jl")` and `Gapjm.Util.degree(x) = ...`

after You include(“Util.jl”) inside `Gapjm` module it is only in `Gapjm` scope, not in `Gapjm.Perms`, etc.

---

<div class="post-metadata">

**Author:** ![Jean\_Michel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jean_michel/32/8282_2.png) [@Jean\_Michel](https://discourse.julialang.org/u/Jean_Michel)\
**Post date:** [October 8, 2018, 12:29am UTC](https://discourse.julialang.org/t/experimental-package-gapjm-jl-porting-some-gap-functionality-to-julia/16002/10 "2018-10-08T00:29:12Z")

</div>

Thanks, I merged your PR
