I will donate US$100.00 to JSoftware on behalf of the first person to
post to the J Forums a model of J's numeric constant notation, as
described in the Dictionary [1].

The model must be implemented as a monadic verb.  The input is a string
(rank 1 literal vector) representing a J numeric constant, as in '0 1234
1j1 7e_3 2p3 _1j16bffff' .  The output is another string, representing a
J sentence that produces the same value as the input when executed, as
in '(0),(1234),(1 j. 1),(7*10^-3),(2*(o.1)^3),( ( (-1) j. 16) #.
''0123456789abcdef'' i. ''ffff'')'  .

The purpose of this verb is to help the reader understand how J
interprets numeric constants, and both the output and the definition of
the verb should further this goal.  Supporting prose is also encouraged.
Try to write your entry so that someone could use it (read it) to
predict the value of an arbitrary J numeric constant, without access to
a J interpreter.

Example:

           pc '0 1234 1j1 7e_3 2p3 _1j16bffff'  NB.  pc=parse constant
        (0),(1234),(1 j. 1),(7*10^-3),(2*(o.1)^3),( ( (-1) j. 16)
#.'0123456789abcdef' i. 'ffff')

           (0),(1234),(1 j. 1),(7*10^-3),(2*(o.1)^3),( ( (-1) j. 16)
#.'0123456789abcdef' i. 'ffff')
        0 1234 1j1 0.007 62.0126 7680j_60960

           (=&". pc) '0 1234 1j1 7e_3 2p3 _1j16bffff' NB.  pc=parse constant
        1 1 1 1 1 1

Rules:
        (0)  I make all final judgments (but I'll consider the
             community's input).

        (1)  Submit your entry to this Forum.

        (2)  Your entry must be a working monad, named
             pc_initialsVersion (for example, I would submit pc_djb0,
             pc_djb1, pc_djb2 etc).

        (3)  An entry only qualifies as a solution if (the tokenization
             of) its output is composed solely of parens, J primitives,
             character literals (for digit indexing only), non-negative
             decimal integers, and _ (negatives, fractional parts, etc
             must be computed like any other transform).  Obviously also
             (-:&". pc_xxx) y  must hold.  Tolerant matching is
             permitted.  Use the default tolerance, 9!:19 ] 2^_44 .

        (3)  The winner is the first person to post a complete, working
             solution.  "Complete" in the sense that it implements J's
             constant notation as described in the Dictionary at [1].
             Sneaky or cute solutions might be awarded extra credit if
             they're interesting (see below) but are disqualified from
             winning.  Employees of JSoftware are eligible to win.  I am
             not.  (I considered handicapping Roger, but at [2] we all
             have access to an implementation of a J constant parser).

        (4)  I will also award extra credit (and extra funds to
             JSoftware) at my discretion.  Credit can be earned by
             anyone, not just the winner.  Credit can be awarded before
             or after a winner is selected.  Examples of credit worthy
             contributions:
                (a)  A particularly novel or brief solution, even if it
                     doesn't win.
                        (i)    Solutions founded on the dyad  ;:
                               qualify.  Probably worth a lot of extra
                               credit.

                        (ii)   Elegant use of the language (e.g. &. ).

                        (iii)  F^:4:  Fully fixed functional form
                               (tacit, anonymous, fixable with f.,i.e.
                               no $:)).

                        (iv)   Solutions that eschew numeric constants
                               altogether, e.g. '(10 #. ''0123456789''
                               i. ''1234''' -: pc_xxx '1234'), or
                               (sillier), '<./$0' -: pc_xxx '_'  .

                (b)  Novel output format or coding style that
                     illuminates the algorithm, particularly if it
                     leverages J as a notation.

                (c)  Elegant error handling (what is pc_xxx '' ?  What
                     is  pc_xxx 'something completely unrelated to
                     numeric constants' ? etc).

                (d)  A good test case, as in  1j1 1x  .

                (e)  A good example where j (the interpreter) deviates
                     from J (the Dictionary), as in 1e3 (J) vs 1E3 (j or
                     12.34r56.78 (j) vs 1234r5678 (J).

                (f)  Identifying a bug (wrt the Dictionary) in the
                     winning solution.

                (g)  A correction to the winning solution to accommodate
                     (e) or (f).

                (h)  A significant non-functional improvement to the
                     winning solution (usual metrics apply: novelty,
                     brevity, velocity, parsimony).  For improvements
                     which make the winning solution faster or leaner,
                     "significant" probably means a factor of 2 or
                     better, but again it's up to me.

                (i)  Solutions that reveal information about how j (the
                     interpreter) may or may not be implemented under
                     the covers (e.g. why  1j1 1x  should be an error,
                     or why 1x ______ used to "work" [3] or why 1x0 is
                     eval'd as 1x1 when 5=9!:12  [4], etc.  See also
                     [5]).

                (j)  Entries containing a solution and prose that would
                     suffice as a formal description of J's numeric
                     constant notation (i.e. as a replacement for [1]).
Extra
                     extra-credit if you post it to the Wiki as an essay
                     or a good Literal Programming writeup, particularly
                     if you employ J as a notation to assist
                     comprehension.  (But remember an entry has to
                     appear on the Forums to be a candidate for
                     winning.)

                (k)  Modifications or additions to these rules to make
                     them clearer, fairer, tighter, etc.  Particularly
                     if the improvement can be re-used for future
                     contests.

                (l)  Anything else particularly impressive.

        -Dan

        [1]  J's constant notation
             http://www.jsoftware.com/help/dictionary/dcons.htm

        [2]  Old J (J7) source:

             http://www.math.uwaterloo.ca/apl_archives/j/early_j/src/j7/
             src.j7/wn.c

        [3]  1x ____ used to "work" :

             http://www.jsoftware.com/pipermail/programming/2006-
             July/002615.html

        [4]  0x1=1x1 on *n?x :

             http://www.jsoftware.com/pipermail/programming/2010-
             September/020609.html

        [5]  J Wiki page on constant notation (& exceptions):
             http://www.jsoftware.com/jwiki/Guides/Constants



----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to