GithubHelp home page GithubHelp logo

utilities's People

Contributors

rlwhitcomb avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

barismutan

utilities's Issues

Allow Calc to return functions from other functions

Would like to be able to do this:
def f1($a, $b) = { $a + $b }; def f2($a, $b) = { $a * $b }; def f($c) = { $c ? f1 : f2 }; f(true)(1,2)
which at the moment gives the following exception:
Exception in thread "main" java.lang.ClassCastException: class info.rlwhitcomb.calc.FunctionScope cannot be cast to class info.rlwhitcomb.calc.FunctionDeclaration (info.rlwhitcomb.calc.FunctionScope and info.rlwhitcomb.calc.FunctionDeclaration are in unnamed module of loader 'app')
at info.rlwhitcomb.calc.LValueContext.getLValue(LValueContext.java:417)
at info.rlwhitcomb.calc.CalcObjectVisitor.getLValue(CalcObjectVisitor.java:3872)
at info.rlwhitcomb.calc.CalcObjectVisitor.visitVarExpr(CalcObjectVisitor.java:1906)
...

Ant target for manual builds to update build.properties more automatically

Right now the manual process is to download the .zip file, run a small Ant script to unzip, then manually edit the build.properties with the latest git revision (short form), possibly update "release.build" to "true" and then run "ant update" or "ant all-install". This is kind of tedious, and possibly there is a way to automate most or all of this process (can we do "wget" or "curl" to download the .zip file?)

WordFind GUI should have a dialog for editing one or more of the dictionaries.

Instead of having to use an external editor to do so. This begs the question of how to get the changes back into the source code, or where the edited file would reside, or how to load it back again .... Something to think about. Or maybe it is just a development tool to make it easier to do the editing, and not really part of the WordFind GUI itself...

Setting Locale in each of the various program may be in error

Trying to implement "$" formatting in Calc is not giving me the expected currency character, MAYBE because I'm not setting the default Locale correctly ("-loc en-US" isn't working in the unit tests). Suggest using Locale.Builder.setLanguageTag instead of the current method, pending further testing.

Calc predefined functions are still wrong in precedence

If you want to do "length(array) - 1" it will complain about "unable to convert array type to decimal", whereas "(length array) - 1" works right.... This shouldn't be, and previous attempts to rearrange the whole presence table has not helped. Maybe "( expr )" should be after the functions, I don't know. Just know it's weird. Or maybe the parens have to be mandatory on function calls, no matter what.

Large duration values in Calc get truncated

For example the min and max dates are "-9999-01-01" to "9999-12-31". Taking the difference results in 7,304,483 days, multiplied by nanosperday (of 86,400,000,000,000) gives a duration value of 631,107,331,200,000,000,000 which is quite a bit larger than the max long of 9,223,372,036,854,775,807, so converting to long before calling NumericUtil.convertToDuration is just wrong...

And in fact, that duration gives "dur@dt" -> t'45347.60062355607703703703703703704d' instead of the correct value of t'7304483d'

Hex, octal, and binary formats for strings in Calc are weird

For instance, "abc"@x -> "616263" ... which isn't a valid input value which will reconstruct the original value ...
So, possible options are:

  • Don't allow strings to be formatted this way (less utility)
  • Define input formats (possibly, 0x'616263') which could be converted back to regular strings, and tweak the format to generate these
  • Output existing escape sequences (such as "\uxxxx") (except this doesn't work for octal or binary)

Produce version of "uniq" written in Java, and therefore usable on Windows

Here are the relevant options from the BSD man page:

NAME
     uniq -- report or filter out repeated lines in a file

SYNOPSIS
     uniq [-c | -d | -u] [-i] [-f num] [-s chars] [input_file [output_file]]

DESCRIPTION
     The uniq utility reads the specified input_file comparing adjacent lines, and writes a copy of each unique input line to the
     output_file.  If input_file is a single dash (`-') or absent, the standard input is read.  If output_file is absent, standard out-
     put is used for output.  The second and succeeding copies of identical adjacent input lines are not written.  Repeated lines in
     the input will not be detected if they are not adjacent, so it may be necessary to sort the files first.

     The following options are available:

     -c      Precede each output line with the count of the number of times the line occurred in the input, followed by a single space.

     -d      Only output lines that are repeated in the input.

     -f num  Ignore the first num fields in each input line when doing comparisons.  A field is a string of non-blank characters sepa-
             rated from adjacent fields by blanks.  Field numbers are one based, i.e., the first field is field one.

     -s chars
             Ignore the first chars characters in each input line when doing comparisons.  If specified in conjunction with the -f
             option, the first chars characters after the first num fields will be ignored.  Character numbers are one based, i.e., the
             first character is character one.

     -u      Only output lines that are not repeated in the input.

     -i      Case insensitive comparison of lines.

Fully implement parameters for user-defined functions in Calc

The grammar is all there in Calc.g4, and there are TODO-type comments, but the implementation is not done yet.

In addition, the library functions in "test/files" do not properly declare nor use parameters as they should (once this is finished, of course).

Allow line continuations in REPL mode of Calc

Normally the Calc REPL mode takes one line of input and executes it, however, sometimes it would be useful to (for instance) define a function over multiple lines, or continue a long line of input on the following lines for readability. So, it would be nice to implement the ability to end a line with \ (or some continuation character) to allow the input to continue to the following lines. In the GUI or in a file this is already possible without any special support.

Inconsistent output of functions when using "eval"

Here's a fail case:
def a={loop $a in 10 { $a }}; a; eval a;

will produce:

Defining function 'a' = { loop $a in 10 { $a } }
a -> 10
$a -> 1
$a -> 2
$a -> 3
$a -> 4
$a -> 5
$a -> 6
$a -> 7
$a -> 8
$a -> 9
$a -> 10
eval a -> 10

So, just invoking the function "a" produces the last value from the loop, and that's it. But, doing "eval a" also does the output from each loop iteration, as well as the final result. This seems weird.

Directory utility is very unfinished

A lot of code is there, ported from "C", but it doesn't really do anything at the moment.

Could probably use rewriting a lot because C-like constructs aren't very useful for Java.

WordFind options are inconsistent

-time is a synonym for both -timing and -maxtime (help is actually consistent with the code, but the option is duplicated)
There may be others

"loop" construct in Calc needs a more general form like C/Java "for" statement

Something like:
loop expr; expr; expr { block }
where expr1 would execute once at the beginning, expr2 is a controlling boolean expression, and expr3 is executed every time through the loop
Unsure whether this use of ';' would conflict with ENDEXPR, or how $VAR would work into this (maybe loop $VAR in expr;expr;expr... would still work, but what would the value be???

Update JavaPreProc to use Antlr grammar

There is an Antlr v4 grammar now in PreProc.g4, which could/should be incorporated into the main processing loop in "processFile".
The grammar is currently commented as "not quite complete", so we should finish it as we see things in the Java code that are not yet incorporated into the grammar.

Specific edits to Calc help

  • Add equation to calculate r (since atan2 calculates theta)
  • Add object . member to dot
  • Some way to vertically line up explanations in 3rd column with symbols in 2nd column of operators table
  • For "round" function, put examples on separate lines (colored) with ">" like in newest stuff
  • Same with "replace", "sort", "factors", and "pfactors" examples (there may be others too)

Add "replace" function for strings in Calc

This will do essentially the same things as "splice" does for objects and arrays, but with strings (and by extension numbers converted to strings).
Syntax: a = replace original_string, pattern, replacement [, options ]
where options can be missing, "all", "first", or "last"
corresponding to Java String.replaceAll, String.replaceFirst, and new functionality for "last".

These new keywords will be treated the same way as the mode option keywords ("on", "off", etc.) as valid identifiers in their own right.

Tweaks needed in Calc help page

  1. The screenshot of the Window Settings does not have the right characters for the Enter/Cmd-Enter keys.
  2. Need closing paren in smart quotes paragraph.
  3. Description of "ISPRIME" should have "?" at the end.

New "splice" function in Calc doesn't work right for objects (maps)

For an array the correct elements are removed from the original array, but if the origin is an object, the elements are arranged into an array, and the removed elements returned are correct (in order of definition), but the original object is not modified (as per the spec). For instance, this illustrates the current behavior for an object:

c = {a: 1, b: 2, c: 3} -> { a: 1, b: 2, c: 3 }; splice c, 1, 1 -> [ 2 ]; c -> { a: 1, b: 2, c: 3 }

Implement env variable TESTER_OPTIONS for "tester" program

I find I have to specify "-dir:test/files" and "-log" every time I manually run tester. It would be nice if these more-or-less constant options could be specified in an environment variable (as CALC_OPTIONS, WORDFIND_OPTIONS, etc.) so that I don't have to type them every time.

There should be an option to ignore the previously set options also so that I could override them without unsetting (and then resetting) the env var.

Date formatting in Calc with @E (U.S. dates) is wrong for negative years.

In ISO-8601 form, d'-9999/01/01' works right, and looks right. However, D'-01/01/9999' works but looks funny (b/c only the year is actually negative, not the month). So, we should be using "D'01/01/-9999' and correspondingly with @e. Although I suppose there is no harm in allowing the "-" first on input, the @e output should have the "-" next to the year.

Add "read" and "write" functions to Calc for file access

  • Result of "read" could be the entire file contents as a string (FileUtilities method).
  • But, there could be options to read in binary and return array of bytes.
  • Need charset for encoding for both directions.
  • Parameter to 'write' would be the string or array (of bytes, presumably) to write.
  • Write would need "overwrite", and "append" flags (at least), maybe "error if exists" also.

Array of bytes would probably be very inefficient (memory-wise) using ArrayScope, so we might need a different object to store this, but then would need more logic in LValueContext to access these via [...] notation, as well as special logic to format, and create elsewhere ... a whole host of things to think about here.

Possible read/write in CSV format as well (with all the CSVFormat options we have available).

Behavior of Calc "join" function with arrays or objects is weird

For example: a=[1,2,3]; join a -> "132", since each of the values is treated as if it were listed individually (as in "join 1,2,3"), so the 3rd value is the "glue" value...
It would be better if with one parameter, which is an array or object, the values are simply concatenated, so that join a -> "123". An optional second parameter would be the "glue" value, so that join a, ',' -> "1,2,3" as you would kind of expect.
The other tricky thing is that the order of the values in an object (map) is undefined (based on a hash function), but it would be better if they were listed in alphabetical order by the key names (maybe??) or in the order of definition (how to figure this out?), but in some predictable order.

Use different lookup technique to speedup WordFind operation

The current exponential time increase means that finding all the combinations for a 15-letter word (such as OXYPHENBUTAZONE !!) takes an enormous amount of time. Seems like we could do better (and indeed, simple programs online take mere seconds instead of hours for such a lookup).

InitializationTask is just wrong

Calling "start()" inside the constructor means that the "run()" method and therefore the subclass' "task()" is started even before the subclass constructor is finished, so the class is not fully constructed yet, and can fail badly because of this.

This question is explored here: https://stackoverflow.com/questions/84285/calling-thread-start-within-its-own-constructor

Need to completely redo this class and use a thread pool, subclass some form of Future, or something that actually works. A factory method might be good: "startAndRunInBackgroundThread(Runnable)" perhaps...

Perhaps it can accept either a Runnable (lambda) or Callable in case there is a single value to return.

Add "version" predefined object to Calc

Possible structure: version -> { major: 2, minor: 2, patch: 18, prerelease: "+a", buildmeta: "2a3ba65" }
This corresponds to the SemanticVersion class fields.

Note: this would also require the Calc REPL command "version" to be redone somehow, or else the predefined variable to be named "versioninfo" or something like that. Potentially we could eliminate the "version", "quit", "help" commands in favor of the ":version", ":quit", etc. flavors instead.

I would also be in favor of just naming "prerelease" as "release" and "buildmeta" as just "build" or just "meta".

Lists should deal gracefully with line continuations

That is, lines that end with "\" meaning the line logically continues on the next line without considering the embedded newline. Especially with "-single" mode, the line-ending character of "\" should be stripped off before continuing, but maybe / probably in all cases.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.