Skip to content

Commit

Permalink
Document usage as a library
Browse files Browse the repository at this point in the history
  • Loading branch information
p-e-w committed Feb 20, 2015
1 parent 90b8762 commit a4b170a
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 5 deletions.
48 changes: 44 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ and provides the continuation

### Symbolic input and output

Sequencer is not limited to processing integers but can identify sequences consisting of arbitrary Symja expressions (provided they can be evaluated numerically). For example, invoking the program with the command line `-u 0 1/2 sqrt(3)/2 1` produces
Sequencer is not limited to processing integers but can identify sequences consisting of arbitrary Symja expressions (provided they can be evaluated numerically). For example, invoking the program with the arguments `0 1/2 sqrt(3)/2 1` produces

```
a(n) = Sin(1/6*Pi*(n-1))
Expand All @@ -50,14 +50,48 @@ Note that parentheses in arguments need to be escaped (`\(`) when running a prog

## Installation and usage

Sequencer requires [Java](https://www.java.com) to run. Download the latest Sequencer JAR from the [releases page](https://github.com/p-e-w/sequencer/releases) and execute it from a terminal with the numbers to be matched as arguments, i.e.
Sequencer requires [Java](https://www.java.com) to run. Download the latest standalone Sequencer JAR (`sequencer.jar`) from the [releases page](https://github.com/p-e-w/sequencer/releases) and execute it from a terminal with the numbers to be matched as arguments, i.e.

```
java -jar sequencer.jar 1 2 3 4 5
```

Running the program without arguments displays a help text explaining the various command line parameters that can be used to fine-tune how searches are performed.

## API

Sequencer can also be used as a library, for which precompiled JARs (`sequencer-library-X.X.X.jar`) are available on the [releases page](https://github.com/p-e-w/sequencer/releases).

The class `Sequencer` provides the method

```scala
def identifySequence(sequence: Seq[String]): Seq[SequenceIdentification]
```

that returns objects of type

```scala
case class SequenceIdentification(formula: String, continuation: Seq[String])
```

When instantiating, the class must be passed a `Configuration` object

```scala
case class Configuration(
maximumComplexity: Int,
maximumIdentifications: Int,
predictionLength: Int,
recurrenceRelations: Boolean,
combinatorialFunctions: Boolean,
transcendentalFunctions: Boolean,
numericalTest: Boolean,
printProgress: Boolean,
outputLaTeX: Boolean
)
```

that controls the behavior of `identifySequence`. For more details, see the source code.

## Development

Sequencer is written in Scala. To compile Sequencer from source, you need [Git](http://www.git-scm.com/), a [JDK](http://www.oracle.com/technetwork/java/index.html), the [Scala compiler](http://www.scala-lang.org/), and [sbt](http://www.scala-sbt.org/). Once all of these are installed and on your `PATH`, you are ready to build and run Sequencer:
Expand All @@ -68,13 +102,19 @@ cd sequencer
sbt run
```

The release JAR can then be created using
The standalone JAR can be created using

```
sbt assembly
```

and will be located at `target/scala-X.XX/sequencer.jar`.
The library JAR can be created using

```
sbt package
```

All generated JARs will be written to `target/scala-X.XX/`.

To develop Sequencer using a Scala IDE, have sbt generate project files with a plugin like [sbteclipse](https://github.com/typesafehub/sbteclipse) or [sbt-idea](https://github.com/mpeltonen/sbt-idea).

Expand Down
12 changes: 12 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
name := "Sequencer"

version := "1.2.0"

organization := "com.worldwidemann"

homepage := Some(url("https://github.com/p-e-w/sequencer"))

libraryDependencies ++= Seq(
"com.github.scopt" %% "scopt" % "3.3.0",
"log4j" % "log4j" % "1.2.17",
Expand All @@ -8,3 +16,7 @@ resolvers += Resolver.sonatypeRepo("public")

assemblyJarName in assembly := "sequencer.jar"

artifactName := { (sv: ScalaVersion, module: ModuleID, artifact: Artifact) =>
"sequencer-library-" + module.revision + "." + artifact.extension
}

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import scopt.OptionParser

object SequencerRunner {
def main(args: Array[String]): Unit = {
println("Sequencer 1.1.0 (https://github.com/p-e-w/sequencer)\n")
println("Sequencer 1.2.0 (https://github.com/p-e-w/sequencer)\n")

// Suppress annoying Symja console output (idea from http://stackoverflow.com/a/8363580).
// This is a very brittle solution. In particular, if we do not use the Console stream
Expand Down

0 comments on commit a4b170a

Please sign in to comment.