sloane 4.0.2 → 4.1.0
raw patch · 5 files changed
+145/−142 lines, 5 files
Files
- README.md +1/−1
- Sloane/Options.hs +1/−7
- sloane.1 +140/−130
- sloane.cabal +1/−1
- sloane.hs +2/−3
README.md view
@@ -41,7 +41,7 @@ author = "Anders Claesson", title = "sloane: A command line interface to the OEIS", year = 2015,- howpublished = "\url{http://akc.is/src/sloane}"+ howpublished = "\url{http://akc.is/sloane}" } ```
Sloane/Options.hs view
@@ -26,10 +26,8 @@ -- | Command line options: data Options = Options {- -- | Search the local DB.- query :: Bool -- | Search oeis.org.- , oeis :: Bool+ oeis :: Bool -- | Print all fields? , longFormat :: Bool -- | Keys of fields to print.@@ -59,10 +57,6 @@ optionsParser = abortOption ShowHelpText (long "help") <*> (Options <$> switch- ( short 'q'- <> long "query"- <> help "Search the local database" )- <*> switch ( long "oeis" <> help "Search oeis.org" ) <*> switch
sloane.1 view
@@ -1,76 +1,31 @@-.TH "SLOANE" "1" "18 Aug 2015" "User Manual" "Version 4.0.0"+.TH "SLOANE" "1" "4 Sep 2015" "User Manual" "Version 4.1.0" .SH NAME .PP-sloane: A command line interface to Sloane\[aq]s OEIS.+sloane \- lookup integer sequences, OEIS A\-numbers, etc. .SH SYNOPSIS .PP-\f[B]sloane\f[] \f[C]OPTIONS\ \-\-oeis\ TERMS...\f[]-.PD 0-.P-.PD-\f[B]sloane\f[] \f[C]OPTIONS\ (\-q|\-\-query)\ A\-NUMBER/SEQUENCE...\f[]+\f[C]sloane\ [\-\-long]\ [\-k\ KEYS]\ [\-n\ N]\ [\-\-all]\ [\-\-monochrome]\ [\-\-json]\ [\-\-oeis]\ TERMS...\f[] .PD 0 .P .PD-\f[B]sloane\f[] \f[C][\-\-invert]\ \-\-filter\f[]+\f[C]sloane\ [\-\-invert]\ \-\-filter\f[] .SH DESCRIPTION .PP-The \f[C]sloane\f[] command provides an interface to OEIS (The On\-Line-Encyclopedia of Integer Sequences).-It can be used online with the \f[C]\-\-oeis\f[] operation, and offline-with the \f[C]\-\-query\f[] operation; offline mode is the default.-.SH OPERATION \-\-oeis-.SS Synopsis-.PP-\f[C]sloane\ [\-\-long]\ [\-k\ KEYS]\ [\-n\ N]\ [\-\-all]\ [\-\-monochrome]\ [\-\-json]\ \-\-oeis\ TERMS...\f[]-.SS Description-.PP-Lookup search terms in Sloane\[aq]s On\-Line Encyclopedia of Integer-Sequences (OEIS).-.SS Options-.TP-.B \-\-long-Long format; print all fields.-.RS-.RE-.TP-.B \-k \f[I]KEYS\f[]-Keys of fields to print (default: SN).-.RS-.RE-.TP-.B \-n \f[I]N\f[]-Fetch at most this many entries (default: 5).-.RS-.RE-.TP-.B \-\-all-Fetch all matching entries (equivalent to \-n 999999).-.RS-.RE-.TP-.B \-\-monochrome-Do not colorize the output.-Useful when piping the output to another program.-.RS-.RE-.TP-.B \-\-json-Output results is JSON format.-.RS-.RE-.SS Examples-.PP-The most common search is for entries matching a sequence of consecutive-terms:+\f[C]sloane\f[] provides a command line interface to Sloane\[aq]s OEIS+(The On\-Line Encyclopedia of Integer Sequences).+It can be used offline (the default) as well as online (with the+\f[C]\-\-oeis\f[] option).+Local searches are faster but a bit less flexible.+A common way to use \f[C]sloane\f[] is to search for entries matching a+sequence of consecutive terms: .IP .nf \f[C]-sloane\ \-\-oeis\ 1,3,19,183,2371,38703+sloane\ 1,3,19,183,2371,38703 \f[] .fi .PP-At the time of writing this particular query would return+At the time of writing this would return .IP .nf \f[C]@@ -79,53 +34,119 @@ \f[] .fi .PP-As this illustrates, the default is to return just the sequence (S) and-the name (N) fields.-To override the default one can use the keys option.-For instance, the following search shows the sequence, name, comments,-and formula fields of the sequence whose A\-number is A006531:+As shown here the default is to return the sequence (S) and the name (N)+fields.+These are the only fields that are available in offline mode.+In online mode all fields are available.+To select among the fields use the \f[C]\-k\f[] option, or, to select+all fields, use to \f[C]\-\-long\f[] option.+The following search would show the sequence, name, comments, and+formula fields: .IP .nf \f[C]-sloane\ \-k\ SNCF\ \-\-oeis\ id:A006531+sloane\ \-k\ SNCF\ \-\-oeis\ 1,3,19,183,2371,38703 \f[] .fi .PP-The next example returns at most 3 results of a free text search:+One can also lookup A\-numbers or do a free text search; see the+\f[B]EXAMPLES\f[] section.+.PP+The \f[C]\-\-filter\f[] option can be very useful when checking a large+number of sequences.+In this mode \f[C]sloane\f[] reads standard input line\-by\-line, if the+sequence read is in the local database, then it is returned to standard+output; if not, it is ignored.+This way one can quickly filter out the sequences from the input that+are in the local database.+To be concrete, assume that \f[I]FILE\f[] contains one sequence per+line.+Then .IP .nf \f[C]-sloane\ \-n\ 3\ \-\-oeis\ "(2+2)\-free\ posets"+sloane\ \-\-filter\ <FILE \f[] .fi .PP-Sloane normally crops long lines to fit the widths of the terminal.-If this is unwanted, pipe the output through cat or less:+returns the subset of the sequences in \f[I]FILE\f[] that are in the+local database.+To also lookup the names of those sequences one could run .IP .nf \f[C]-sloane\ \-\-long\ \-\-oeis\ id:A000110\ |\ less\ \-R+sloane\ \-\-filter\ <FILE\ |\ sloane \f[] .fi-.SH OPERATION \-\-query-.SS Synopsis .PP-\f[C]sloane\ [\-\-long]\ [\-k\ KEYS]\ [\-n\ N]\ [\-\-all]\ [\-\-monochrome]\ [\-\-json]\ (\-q|\-\-query)\ A\-NUMBER/SEQUENCE...\f[]-.SS Description-.PP-Search locally against a downloaded local database of known sequences.-This type of query is less flexible, but faster, than using the-\f[C]\-\-oeis\f[] operation: With \f[C]\-\-query\f[] one can only lookup-A\-numbers and seqences; free text searches are not supported.-Also, the fields returned by \f[C]\-\-query\f[] are \[aq]S\[aq] and-\[aq]N\[aq].-.SS Examples+The way this works is that if \f[C]sloane\f[] is called without search+terms then it reads from standard input.+.SH OPTIONS+.TP+.B \-\-oeis+Online search; lookup the provided terms in Sloane\[aq]s On\-Line+Encyclopedia of Integer Sequences (OEIS).+.RS+.RE+.TP+.B \-k \f[I]KEYS\f[]+Keys of fields to print (default: SN).+.RS+.RE+.TP+.B \-\-long+Long format; print all fields.+.RS+.RE+.TP+.B \-n \f[I]N\f[]+Fetch at most this many entries (default: 5).+.RS+.RE+.TP+.B \-\-all+Fetch all matching entries (equivalent to \-n 999999).+.RS+.RE+.TP+.B \-\-monochrome+Do not colorize the output.+Useful when piping the output to another program.+.RS+.RE+.TP+.B \-\-json+Output results is JSON format.+.RS+.RE+.TP+.B \-\-invert+Return sequences \f[I]not\f[] in the database (used with+\f[C]\-\-filter\f[]).+.RS+.RE+.TP+.B \-\-update+Update the local database.+.RS+.RE+.TP+.B \-\-version+Print version information.+.RS+.RE+.TP+.B \-\-help+Briefly describe the available options.+.RS+.RE+.SH EXAMPLES .PP Lookup A\-numbers: .IP .nf \f[C]-$\ sloane\ \-\-query\ A000111\ A000112+$\ sloane\ A000111\ A000112 S\ A000111\ 1,1,1,2,5,16,61,272,1385,7936,50521,353792,2702765, N\ A000111\ Euler\ or\ up/down\ numbers:\ e.g.f.\ sec(x)\ +\ tan(x)..@@ -135,11 +156,11 @@ \f[] .fi .PP-Lookup a sequence:+Lookup a sequence (limit to at most two results): .IP .nf \f[C]-$\ sloane\ \-n2\ \-q\ 1,1,2,5,15,52,203,877,4140,21147,115975,678570,+$\ sloane\ \-n2\ 1,1,2,5,15,52,203,877,4140,21147,115975,678570, S\ A000110\ 1,1,2,5,15,52,203,877,4140,21147,115975,678570,4213597, N\ A000110\ Bell\ or\ exponential\ numbers:\ number\ of\ ways\ to\ partition..@@ -148,64 +169,50 @@ N\ A192128\ Number\ of\ set\ partitions\ of\ {1,\ ...,\ n}\ that\ avoid.. \f[] .fi-.SS Options .PP-Same as for the \f[C]\-\-oeis\f[] operation.-.SH OPERATION \-\-filter-.SS Synopsis+Lookup a sequence generated by \f[B]hops\f[](1):+.IP+.nf+\f[C]+$\ hops\ \[aq]y=1+integral(2*y^2\-y);laplace(y)\[aq]\ |\ sloane++S\ A000670\ 1,1,3,13,75,541,4683,47293,545835,7087261,102247563,+N\ A000670\ Fubini\ numbers:\ number\ of\ preferential\ arrangements\ of..++S\ A034172\ 1,1,3,13,75,541,4683,47293,545835,7087261,102247563,+N\ A034172\ Nearest\ integer\ to\ n!/(2*log(2)^(n+1)).+\f[]+.fi .PP-\f[C]sloane\ [\-\-invert]\ \-\-filter\f[]-.SS Description+Show the sequence, name, comments, and formula fields of the sequence+whose A\-number is A006531:+.IP+.nf+\f[C]+sloane\ \-k\ SNCF\ \-\-oeis\ id:A006531+\f[]+.fi .PP-To check a large number of sequences one can use \f[C]\-\-filter\f[].-When this option is set, \f[C]sloane\f[] reads the standard input-line\-by\-line, if the sequence read is in the local database, then it-is returned to the standard output; if not, it is ignored.-This way one can quickly filter out the sequences from the input that-are in the local database.-In other words, assuming that \f[I]FILE\f[] contains one sequence per-line,+Return at most 3 results of a free text search: .IP .nf \f[C]-sloane\ \-\-filter\ <FILE+sloane\ \-n\ 3\ \-\-oeis\ "(2+2)\-free\ posets" \f[] .fi .PP-returns the subset of the sequences in \f[I]FILE\f[] that are in the-local database.-To also lookup the names of those sequences one could, for instance, run+\f[C]sloane\f[] normally crops long lines to fit the widths of the+terminal.+If this is unwanted, pipe the output through cat or less: .IP .nf \f[C]-sloane\ \-\-filter\ <FILE\ |\ sloane\ \-q+sloane\ \-\-long\ \-\-oeis\ id:A000110\ |\ less\ \-R \f[] .fi-.SS Flag-.TP-.B \-\-invert-Return sequences \f[I]not\f[] in the database.-.RS-.RE-.SH ADDITIONAL OPERATIONS-.TP-.B \-\-update-Update the local database.-.RS-.RE-.TP-.B \-\-version-Print version information.-.RS-.RE-.TP-.B \-\-help-Briefly describe the available options.-.RS-.RE .SH KEYS .PP-These are the keys used by OEIS <http://oeis.org/eishelp2.html>.+These are the keys used by the OEIS (http://oeis.org/eishelp2.html). .IP .nf \f[C]@@ -239,13 +246,16 @@ .fi .SH NOTES .PP-Please use the \f[C]\-\-oeis\f[] option with moderation as not to+Please use the \f[C]\-\-oeis\f[] option with some moderation as not to overburden the OEIS\-server; see OEIS\[aq] policy on searching the-database:-<http://oeis.org/wiki/Welcome#Policy_on_Searching_the_Database>.+database (http://oeis.org/wiki/Welcome#Policy_on_Searching_the_Database). .SH SEE ALSO .PP-<http://akc.is/src/sloane>+\f[B]hops\f[](1) <http://akc.is/hops>+.PD 0+.P+.PD+Source code for \f[C]sloane\f[]: <http://akc.is/sloane> .SH AUTHOR .PP Anders Claesson <http://akc.is>
sloane.cabal view
@@ -1,5 +1,5 @@ Name: sloane-Version: 4.0.2+Version: 4.1.0 Synopsis: A command line interface to Sloane's OEIS. Description: A command line interface to Sloane's On-Line Encyclopedia of
sloane.hs view
@@ -36,7 +36,7 @@ import Sloane.Bloom import Sloane.DB -nameVer = "sloane 4.0.2" :: String+nameVer = "sloane 4.1.0" :: String oeisURL = "https://oeis.org/search" :: URL strpdURL = "https://oeis.org/stripped.gz" :: URL namesURL = "https://oeis.org/names.gz" :: URL@@ -87,7 +87,7 @@ | oeis opts = return $ SearchOEIS (tojson opts) (limit opts) view (unwords (terms opts)) - | query opts = do+ | otherwise = do sdb <- readSeqDB cfg ndb <- readNamesDB cfg let parseInp t = fromMaybe (error "cannot parse input")@@ -98,7 +98,6 @@ <$> case map B.pack (terms opts) of [] -> readStdin ts -> return ts- | otherwise = readInput (opts {query = True}) cfg where view = (termWidth cfg, palette opts, keys opts)