From Rosetta Code
This is an example of a library. You may see a list of other libraries used on Rosetta Code at Category:Solutions by Library.

Wren-psieve provides Wren bindings for the C++ library primesieve which can generate primes orders of magnitude faster than any pure Wren code. It consists of two classes: Primes and LPrimes. The former should be used for numbers less than 2^53 (Wren's safe integer threshold) and the latter for greater numbers but less than 2^64 which is the maximum primesieve itself can handle.

It is the forty-fifth in a series of modules (listed on the language's main page) designed to assist with writing Rosetta Code tasks so the same code does not have to be written or copy/pasted time and time again thereby bloating a task's script code unnecessarily.

To use it you need to copy the Wren source code (in the talk page) to a text file called psieve.wren and place this in the same directory as the importing script so the Wren-psieve executable can find it.

Currently, Wren-cli does not support plug-ins though this or similar functionality is likely to be added in a future version (it's already present in DOME). Consequently, scripts using the Wren-psieve module must be run under the control of a special executable whose source code (wren-psieve.c) is also included in the talk page. This executable translates Wren method calls to calls to the corresponding primesieve functions and can be built with a command line such as the following using GCC under Linux:

   $ gcc -O3 wren-psieve.c -o wren-psieve -lprimesieve -lwren -lm  

If you then want to run a script called myscript.wren you would type at the command-line:

   $ ./wren-psieve myscript.wren

myscript.wren should include a line such as the following to import the class or classes you want to use in that particular script:

   import "./psieve" for Primes, LPrimes

The same executable can be used to run any other Wren-psieve scripts unless they require additional functionality not available in Wren itself in which case the C code will need to be suitably modified and recompiled.

primesieve is licensed under the BSD 2-Clause Licence.

Pages in category "Wren-psieve"

The following 4 pages are in this category, out of 4 total.