Skip to content

Commit

Permalink
Merge pull request #7 from JuliaMath/sb/export
Browse files Browse the repository at this point in the history
Conditionally export/import symbols.
  • Loading branch information
simonbyrne committed May 27, 2016
2 parents 607860d + 97a7a2a commit 078a15c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

Julia functions for computing prime numbers.

## Usage

At the moment, this repository just contains the following functions which have been duplicated from Base Julia:

factor(n) -> Dict
Expand Down Expand Up @@ -50,4 +52,7 @@ true
> Returns a prime sieve, as a `BitArray`, of the positive integers (from `lo`, if specified)
up to `hi`. Useful when working with either primes or composite numbers.
None of these are currently exported, so need to be explicitly imported before use.
To avoid naming conflicts with Base, these are not exported for Julia version 0.4. In this case you will need to explicitly import the symbols:
using Primes
import Primes: isprime, primes, primesmask, factor
8 changes: 8 additions & 0 deletions src/Primes.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
__precompile__()
module Primes

if VERSION >= v"0.5.0-dev+4340"
if isdefined(Base,:isprime)
import Base: isprime, primes, primesmask, factor
else
export isprime, primes, primesmask, factor
end
end

# Primes generating functions
# https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
# https://en.wikipedia.org/wiki/Wheel_factorization
Expand Down

0 comments on commit 078a15c

Please sign in to comment.