System/Interpreter/Requests/Closed

From J Wiki
Jump to: navigation, search
Requests: Interpreter   Bugs: Interpreter

Please restrict the headings to just two levels, with the actual bug reports placed at the top level; sign your submission using ~~~~; register the entry in the comment field below.


The following requests for interpreter changes have been closed for the reasons given.



{:: performance

Syntactically, {:: is a perfect choice for scattered indexing without boxing.

   A=: 100 100 ?@$ 100
   I=: 100000 2 ?@$ 100
   $(<"1 I){A
100000

   (I {:: A) -: (<"1 I){A
1

However, it does not perform very well compared to { with boxed argument, which could make it a candidate for special code.

   ts=: 6!:2 , 7!:2@]
   3 ts'I {:: A'
0.319013 6.26961e7
   3 ts'(<"1 I){A'
0.0432512 9.95654e6

Least memory is taken by such construst

   (I {:: A) -:  I (<@[ { ])"1 _ A
1
   3 ts'I (<@[ { ])"1 _ A'
0.241267 591872

-- Oleg Kobchenko <<DateTime(2006-01-18T19:00:23Z)>>

Status: closed. Use <"1@[ { ]


case. 0 case. 1 do.

Currently, J's select. implementation requires that each case. be accompanied by a do. block. For some problem domains, it would make sense for multiple cases to share the same do. block. This could be supported with J's select. notation by allowing multiple case. entries next to each other followed by a single do. block. I ran across this today, trying to implement some support for dimensional analysis in J -- you need to deal with + and - in the same fashion.

-- User:Raul Miller <<DateTime(2007-10-24T13:22:26Z)>>

    • You can express "case. 0 case. 1 do." in two ways: case. 0;1 do. or fcase. 0 do. case. 1 do.. Extended example:
   case =: 3 : 0
	select. y
		 case. 'joe';'john'   do. z=.'male'
		 case. 'jane';'jill'  do. z=.'female'
		fcase. 'fido';'rex'   do. z=.'not relevant'
		 case.                do. z=.'(unknown)',~".''' '',~z'
	end.
)

   (,. case&.>) ;:'joe john jill jane fido rex whiskers'
+--------+----------------------+
|joe     |male                  |
+--------+----------------------+
|john    |male                  |
+--------+----------------------+
|jill    |female                |
+--------+----------------------+
|jane    |female                |
+--------+----------------------+
|fido    |not relevant (unknown)|
+--------+----------------------+
|rex     |not relevant (unknown)|
+--------+----------------------+
|whiskers|(unknown)             |
+--------+----------------------+
 -- Dan Bron <<DateTime(2007-10-24T15:14:56Z)>>
    • Knuth would be happy:
   gtch  =:  3 : 0
	select. y
		case. 0 do. goto_case1.   NB.  Considered harmful
		case. 1 do. label_case1. 'Judge not, lest ye be judged'
	end.
)
|control error
|   [1]		case. 0 do. goto_case1.   NB.  Considered harmful
|   gtch=:    3 :0
 Technically, this is a bug (i.e. it contradicts the Dictionary), but it's not worth reporting formally.

-- Dan Bron <<DateTime(2007-10-25T02:35:03Z)>>

Status: closed. As mentioned above, use case. case1;case2;... or fcase.


Dictionary page for Special Code nubbed

The Dictionary J601 Appendix "Special Code" has two copies of each of the following entries.

m&i. monad also m&i: -.&m e.&m ; see the J 5.04 release notes
;@:(<;.0) dyad special code; see the J 5.03 release notes
i.<./ monad also i.>./ and i:<./ and i:>./ ; special code for integer and floating point lists (see the J 5.04 release notes)
x&(128!:3) monad special code to pre-compute look-up table of CRC values for each byte

It would be nice if one of these got deleted. Thanks.

-- User:B Jonas <<DateTime(2008-02-01T08:10:35Z)>>

P.S. Oh, and verify that they're really exact copies. I might have overlooked something.

  • The duplicates are so that you can find the items while looking up different things. e.g. for m&i. you can find it looking for & or for i. . -- Roger Hui <<DateTime(2008-02-01T15:20:08Z)>>

Status: closed, documented in NuVoc


document fit more completely

I'd like to request that the dictionary page for fit (customize, !.) documents all cases when fit works, not only some.

In particular, applied to key (monadic /.), fit is taken by the interpreter as key with tolerance, as Niemiec points out on the forum eg.

   (1 + 1e_14 * 1 0 0 1 0) </. 'abcde'
+-----+
|abcde|
+-----+
   (1 + 1e_14 * 1 0 0 1 0) </.!.0 'abcde'
+--+---+
|ad|bce|
+--+---+

and it seems that this isn't documented in the dictionary anywhere.

Applied to expand (diadic #^:_1 and also monadic m&#^:_1), fit sets the fill element, eg.

   1 0 0 1 0 #^:_1!.'-' 'ab'
a--b-
   1 0 0 1 0&#^:_1!.'-' 'ab'
a--b-

which is documented clearly on the dictionary page for ^: but not on the page for !..

I would like to request that every left argument that the fit conjunction handles (which may include ones I don't know about) be listed on the dictionary page for fit.

-- User:B Jonas <<DateTime(2010-02-22T01:24:37+0200)>>

The way I understand it, under the covers ! just sets a global tolerance flag (i.e. 9!:19), which is used by all comparisons while it is in force. "All comparisons" obviously means uses of the verb =, which is embedded in the implementations of many related primitives (e.g. such as /. or i. etc), and using fit in conjunction with any of these primitives will have the "tolerant" effect.

An even further removed effect is that !. can be applied to verbs for uses unrelated to tolerance (e.g. in {.!.n) yet it still sets the conditions for tolerance, so you might get tolerant effects from using !. applied to non-comparative verbs (where those verbs contain comparatives under the covers).

-- Dan Bron <<DateTime(2010-02-22T12:21:23-0300)>>

Wait. Does key-fit really work like that, setting the global tolerance setting temporarily?

   (1+1e_14*1 0 0 1 0) (1:=1:+1e_14"_)/. 'abcde'
1
   (1+1e_14*1 0 0 1 0) (1:=1:+1e_14"_)/.!.0 'abcde'
0 0
   (1+1e_14*1 0 0 1 0) ([:9!:18($0)"_)/. 'abcde'
5.68434e_14
   (1+1e_14*1 0 0 1 0) ([:9!:18($0)"_)/.!.0 'abcde'
0 0
 You're right, it does.  So that's why it's undocumented! :-)

-- User:B Jonas <<DateTime(2010-02-23T00:18:38+0200)>> If you want a comprehensive list of "fit"s and the types of arguments they can take:

   require'strings PRIM qdoj'   NB.  See links for PRIM and qdoj
	
   fit     =.  {.;:'!.'
   nouns   =.  <;._1'/0/'' ''/a:/(s:a:)'
   nvs     =.  nouns,f`'' [ erase'f' NB.  Ensure f is interpreted as an (undefined) proverb
   TESTS   =.  (, ,&'^:_1'&.>) ;:^:(0 -@< L.)&.> PRIM_VERBS, (, { nvs ; <PRIM_ADVERBS) , (, { nvs ; (PRIM_CONJUNCTIONS -. fit) ; <nvs)
   fits    =.  (#~ 3 : ' +1 :y label_. 1' ::0:&>) ;&.> ,{ nouns ,&<~ fit ,&.>~ TESTS -. '0 : 0';'0 : 0^:_1'  NB.  Don't execute (0 : 0) or it will require input
   groups  =.  ({.@:-.&(nouns,nvs,fit)@:;:&>) fits
   fitHTML =.  0 _ qdojH '!.'
   fitHtbl =.  ('Fit applies to the following verbs';'<table') ('</table' (] {.~ i.&1@:E.) ] }.~ [: ((1{::]){~ [: i.&1@:, <:/&>/)I.@:E.&tolower L:0) fitHTML
   fitTbl  =.  _2 (,~ ;:&.>)~/\ deb&.> LF cut toJ html fitHtbl
   defs    =.  'NB.  ',^:(0<#@])L:0 fitTbl ((a:,~{:"1@:[) {~ [: i:&1"1@:|: {."1@:[ e.S:1~ ]) ~. groups
   smoutput > (,. ' '&,.)&.>/ <@:>"1 |: defs ,.~ groups ]/. fits
#:!.0                                                                                 NB.  Tolerance * Tolerance
#!.0      #!.' '     #!.a:     #!.(s:a:)  #^:_1!.0 #^:_1!.' ' #^:_1!.a: #^:_1!.(s:a:) NB.  * Fill
$.!.0
$!.0      $!.' '     $!.a:     $!.(s:a:)                                              NB.  * Fill
*.!.0                                                                                 NB.  * Tolerance
*!.0                                                                                  NB.  Tolerance *
+.!.0                                                                                 NB.  * Tolerance
,.!.0     ,.!.' '    ,.!.a:    ,.!.(s:a:)                                             NB.  * Fill
,:!.0     ,:!.' '    ,:!.a:    ,:!.(s:a:)                                             NB.  * Fill
,!.0      ,!.' '     ,!.a:     ,!.(s:a:)                                              NB.  * Fill
-.!.0                                                                                 NB.  * Tolerance
-:!.0                                                                                 NB.  * Tolerance
;!.0      ;!.' '     ;!.a:     ;!.(s:a:)
<.!.0                                                                                 NB.  Tolerance *
<:!.0                                                                                 NB.  * Tolerance
<!.0                                                                                  NB.  * Tolerance
=!.0                                                                                  NB.  Tolerance * Tolerance
>.!.0                                                                                 NB.  Tolerance *
>:!.0                                                                                 NB.  * Tolerance
>!.0                                                                                  NB.  * Tolerance
^!.0                                                                                  NB.  * Stope function and polynomial based thereon
{.!.0     {.!.' '    {.!.a:    {.!.(s:a:)                                             NB.  * Fill
{:!.0     {:!.' '    {:!.a:    {:!.(s:a:)
|.!.0     |.!.' '    |.!.a:    |.!.(s:a:)                                             NB.  * Fill
|!.0                                                                                  NB.  * Tolerance
~.!.0                                                                                 NB.  Tolerance *
~:!.0                                                                                 NB.  Tolerance * Tolerance
e.!.0                                                                                 NB.  Tolerance * Tolerance
i.!.0                                                                                 NB.  * Tolerance
i:!.0                                                                                 NB.  * Tolerance
p.!.0                                                                                 NB.  * Stope function and polynomial based thereon
x:!.0
E.!.0                                                                                 NB.  * Tolerance
f /.!.0
f ^: 0!.0 f ^: a:!.0 f ^: f!.0
}}}  Where names starting with `PRIM_` are defined by my [[JSvn:DanBron/trunk/environment/primitive_classes.ijs|primitive classes]] utility, and `qdoj` and `html` are defined by my [[JSvn:DanBron/trunk/uncategorized/qdoj.ijs|dictionary quoting]] utility.<<BR>>
  Of course, this makes some assumptions about !., specifically that the left and right arguments are a verb and a noun respectively, and for the noun type is more important than shape or value for domain determination (and this isn't always true).  And it doesn't tell you if the customization applies to the derived monad, or dyad, or both.  And very obviously it can't give you the definitions of the derived verbs, where the DoJ doesn't.  But it's a start.  And for the most part, I'd expect the unspecified definitions to be "obvious" or expected; in particular I expect the form comparison_verb!.0 to invoke the "tolerant" case (where comparison_verb calls = somewhere under the covers; e.g. x: as opposed to ;, which [[JDic:../release/raze602|specifies fill]]).

-- Dan Bron <<DateTime(2010-02-24T15:02:28-0300)>> I realized that while f^:0!.0 is valid, f^:_1!.0 probably wouldn't be (a tighter restriction would be to only permit f^:v!. where v e. _ __ or is the verb _:, because otherwise there's no comparison, I think). Anyway, we can abuse this little observation to test for inverses which which fit admits -- fit will return a domain error for all f^:_1!.n except where Roger has specifically allowed (of course, we could fit "any" inverse using f^:_1:!.n but that would allow any f, and wouldn't tell us which ones were "real").

Anyway, turns out the only inverse fit permits is #^:_1 (for fill, just like for #).

-- Dan Bron <<DateTime(2010-02-25T10:06:09-0300)>>

Status: closed, documented in NuVoc


Document interpreting locatives completely in Dictionary

The j602 Dictionary tells what names are locatives, but it does not give the complete rules for how a locative is broken into parts and interpretted.

For example, it's not obvious which of these names are valid and what they mean: a_b_c_ a__b__c a__b_c_ a___b. From experimenting with j701 on x86-linux, a_b_c_ means a_b in the locale c; a__b__c is a doubly indirect locale reference; but a__b_c_ is an error even though I think it would be useful if it was an indirect reference for the name a in the locale referred to by b_c_. In any case, I'd like to see definitive and concrete rules though, not only examples.

-- User:B Jonas <<DateTime(2010-08-26T00:12:53+0200)>>

Status: closed, documented in NuVoc