JuliaMath / Primes.jl

Prime numbers in Julia
Other
99 stars 32 forks source link

result of `factor` is no more copy-pastable #62

Closed rfourquet closed 6 years ago

rfourquet commented 6 years ago

E.g.

julia> factor(20)
2^2 ⋅ 5

Before, the operator (\cdot) was defined in Base (equivalent to dot), so, the expression 2^2 ⋅ 5 could be pasted back in the terminal and produce the input number, ie. 20. Now it works only if LinearAlgebra is imported. I see few solutions:

  1. document that LinearAlgebra must be imported for that to work
  2. change to *
  3. change to * in the show method when we can detect that LinearAlgebra is not loaded
  4. have the show(factor(20)) use * and keep for the display at the REPL (suggested by @HarrisonGrodin, if I understood correctly)
  5. have Primes depend on LinearAlgebra (I hope no-one will support this one!)

I favor 1. and then 2.. I don't like 3 because the output depends on global state, and I find 4. to be slighly overkill. But after all, the star * is not so ugly, so 2. may be the most pragmatic solution. Other ideas?

ararslan commented 6 years ago

I'm for 2

HarrisonGrodin commented 6 years ago

I'm not particularly excited about any usage of LinearAlgebra here; it seems unrelated and not necessary as a dependency. I would be in favor of 2, for parity with the Base function name.

(If retaining is important, it seems like 4 would be a good choice. However, I doubt it would be necessary; sorry for the lack of clarity there. :slightly_smiling_face:)

rfourquet commented 6 years ago

Alright, let's go with 2 !