Outstanding requests for J interpreter extensions and enhancements. (Library extensions and enhancements are on another page.)
Requests and responses in 2005, 2006, 2007.
Contents
- {:: performance
- make x&(#.^:_1) invertible
- uncaught `throw.`
- case. 0 case. 1 do.
- reinstate <;.1^:_1
- cut to fit
- x and y in adverbs and conjunctions
- verb pipelines
- rank of q:^:_1
- Dictionary page for Special Code nubbed
- make dyad ". invertible
- make tacit scalar replacement invertible
- special code for tacit scalar replacement
- redefine u;.0 y
- Expand 15!: in the Dictionary
- Change ;: dyad
- extend Cut
- extend Evoke Gerund
- document fit more completely
- extend fit conjunction
- Document interpreting locatives completely in Dictionary
- Allow proverbs that are temporarily invalid to be created from atomic form
- Allow @ with noun right argument
{:: 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
1However, 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.95654e6Least memory is taken by such construst
(I {:: A) -: I (<@[ { ])"1 _ A
1
3 ts'I (<@[ { ])"1 _ A'
0.241267 591872-- OlegKobchenko 2006-01-18 19:00:23
make x&(#.^:_1) invertible
Please make the monad x&(#.^:_1) (and x #.^:_1 ], x #.^:_1 [, and any other likely forms) invertible:
#.^:_1 b. _1 #. (44&#.)^:_1 b. _1 44&#. 44&(#.^:_1) b. _1 |domain error | 44&(#.^:_1)b._1
-- DanBron 2007-03-12 17:05:34
This idea was seconded by HenryRich
uncaught `throw.`
It turns out that uncaught throw. terminates execution with no message or other indication what is going on. it would be nicer if it said something, like error message.
-- AndrewNikitin 2007-09-06 17:07:27
Turns out that throw. does have a specific error code, 55; see DanBron/Pretix/Tacit for details. We can use this fact to detect an uncaught throw., with only a small change to application code.
We'll use the foreigns 9!:27 and 9!:29 to trigger a sentence when control is returned to immex. The sentence will use 13!:11 to check the last error code; if it's 55, we'll raise an assertion with a custom error message.
Here goes:
start_my_app =: 3 : 'if. 0 -: y do. app y else. throw. end.' argument =: 1 9!:27 '(''uncaught throw.''13!:8 a:i.~9!:8)^:(55 -: 13!:11)$0' start_my_app argument [ 9!:29 [ 1 |uncaught throw. | ('uncaught throw.'13!:8 a:i.~9!:8)^:(55-:13!:11)$0The only changes required to application code is the single call to 9!:27 and the execution of 9!:29[1 on the same line as the invocation of the application (assuming that 9!:27 was not already being used) .
Note that the condition "55=13!:11'' on return to immex" virtually guaruntees that the assertion will only occur on an uncaught throw., but it's not watertight. If the last error was indeed a throw., but it was caught and handled by an appropriate catcht. and the application completed successfully, then 9!:27 will still raise an error.
One workaround is to "reset" the error code within each catcht. block; e.g. 3 : 'try. ... catcht. 13!:8@:1: ::] result_of_catcht end.'.
Just an idea.
-- DanBron 2008-01-14 20:02:40
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.
-- Raul Miller 2007-10-24 13:22:26
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) |
+--------+----------------------+-- DanBron 2007-10-24 15:14:56
- 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.
-- DanBron 2007-10-25 02:35:03
reinstate <;.1^:_1
I observe:
<;.1^:_1 <;.1 '/one/two' |nonce error | <;.1^:_1<;.1'/one/two'
That is, the inverse of <;.1 is momentarily undefined. I request that the previous inverse, ;, be reinstated (at least under limited circumstances).
I know the general definition of x&(<;.1)^:_1 is a tricky problem. But I am not sure that it applies to the inverse of the monad, <;.1^:_1.
Even if the monad's inverse suffers from the same complications, there are simple cases where ; would suffice, and I request that they be implemented as such. The nonce error should be retained where ; is not obviously sufficient.
An example simple case is the above: a vector of boxes where each box contains a vector (I can't think of a case where <;.1 would produce boxed scalars, but perhaps the "simple case" could be generalized to include those, too).
If this proposal is adopted, I submit the parallel proposal that special code which supports phrases of the form: ;@:(<@:u;.1) be extended to support phrases of the form u&.>&.(<;.1).
These proposals apply to <;.2 as well as <;.1. They may also apply to the negative counterparts, <;._1 and <;._2, but that is less clear. For a fuller proposal on how to handle those inverses, see cut to fit
You may see the original request on the Forums, as well as an earlier inquiry.
-- DanBron 2007-10-30 14:32:26
cut to fit
Similar to an old request of mine, I propose an extension to ;..
The request is for a new application of !.. Fit should apply to monads derived from the cut conjunction such that:
u;._1!.n ↔ u;._1 @: (n&,) u;._2!.n ↔ u;._2 @: (,&n) u;. 1!.n ↔ u;. 1 @: (n&,) u;. 2!.n ↔ u;. 2 @: (,&n)
and when u =: < then the respective inverses are:
[: }.@:; n&,&.>
[: }:@:; ,&n&.>
}.@:;
}:@:;I'm not sure what do to for inverses of other u, as u^:_1 is probably not what's wanted. (For example, the inverse of < is > but what we want here is ; instead.)
However, that is not a large obstacle, because I think that:
u&.>&.(<;.m!.n)
will mostly cover the ground. Given that, I believe the idiom should be given special consideration and be supported by special code.
The optimization would ideally apply for all u, but it should at least apply to all u which special code already supports in ;@:(<@:u;.1) (viz my previous request). Special code which supports the idioms <@:u;.m and u&.>@:(<;.m) might also be considered for extension.
Motivations and disincentives for implementing this proposal are as detailed in the original Forum message:
- Advantages:
- Concise.
- Solves a common problem.
- No worrying about losing the shard.
- Backwards compatible.
Centralized, easily optimized. In particular, in <;._2 y,n the catenation (and attendant copying of y) need not be performed.
Could easily provide for other optimizations which would support a large body of extant and likey future code. In particular, f&.>&.(<;._2!.n) could be optimized for well-behaved f (the initial definition of "well behaved" might be "doesn't change the type or shape of its argument"). For example:
dtb&.>&.(<;._2!.LF) NB. dtb from lines
though this is "poorly behaved" because it changes the shape of its argument.In the spirit of !.
In the spirit of ^:_1
- Drawbacks (in addition to those associated with every backwards-compatible change to the language):
<;._2 sans fit couldn't have an inverse, or, if it did, it would be inconsistent with the definition of the inverse of fitted cut (cf. previous request).
Every !. reduces the consistency of J; they should be used sparingly, if at all.
-- DanBron 2007-10-30 00:19:42
x and y in adverbs and conjunctions
+ 1 :'y' 0 |value error: y | y + 1 :'v=.y' 0 0
Could we at some point have an option to turn off the situational definition of x and y -- where x really means u and y really means v if neither u nor v are present?
-- Raul Miller 2007-11-05 22:06:46
verb pipelines
I request an extension to the conjunction `:; I would like to use it to produce verb pipelines. That is, I would like f0`f1`:1 to be equivalent to f0@:f1 , f0`f1`f2`:1 to be equivalent to f0@:f1@:f2 and so on.
The function code 1 is arbitrary and may be anything you like. But I suggest naming the code pipe (analogous to 6, train).
You might also consider another code, similar to the above, except the connecting conjunction is @ instead (I think of f@g@h as an assembly line, but the word assemble is loaded in J, so you might consider conveyor or something else suggestive).
Here is a model of the proposed extension:
eg =: 2 : 0 NB. Evoke Gerund
if. n e. 1 2 do.
m =. }: , m ,. n { a: , ;:'@:@'
m`:6
else.
m`:n
end.
)
f0`f1 eg 1
f0@:f1
f0`f1`f2 eg 1
f0@:f1@:f2
f0`f1 eg 2
f0@f1I note that that `:6 accepts verb arguments, and treats them as length-one gerunds. If you wish to make `:1 consistent with that model, substitute ({.u`]) ,. for m ,..
-- DanBron 2007-12-21 21:32:32
Regarding the last point, i.e. what to do for verb arguments, other treatments are possible. Most of them will break the analogy between `:6 and `:1 , but that might be acceptable if the extension is useful enough.
One such candidate is to treat verb (train) arguments like a list of verbs; that is, treat a verb train like a gerund, and convert the train into a pipeline. Here is an extension of the model that does just that, using t2g from train to gerund:
eg =: 2 : 0 NB. Evoke Gerund if. verb -: nc {.;:'u' do. m =. u t2g end. if. n e. 1 2 do. m =. }: , m ,. n { a: , ;:'@:@' m`:6 else. m`:n end. ) + eg + (++) eg 2 +@+ (++++) eg 2 NB. More concise than +`+`+`+ eg 2 +@+ (+/+/\(+/%#)----) eg 2 +/@(+/\)@(+/ % #)@-@-@-@- NB.! Rightmost hooks not handled properly. (-(--)) eg 2 -@-@-I do not consider this further extension as useful or important as the original, but I thought I'd throw the idea out there.
In fact, perhaps it would be better to separate t2g out as its own function code; since it is the "inverse" of the gerund-to-train adverb `:6, the code _6 is a mnemonic choice.
If so implemented, one could write one's own train-to-pipeline adverb as (`:_6)(`:1). Though, given that applying that adverb would take a minimum of 6 words/10 chars, the train in (train)`:_6`:1 would have to be pretty long to make it a more attractive option than writing the all the @: in the first place.
But it might have other uses.
-- DanBron 2007-12-21 21:48:12
rank of q:^:_1
I suggest the inverse of q: be */"1 rather than */. The monad q: produces rank-1 arrays of integers, so its inverse should apply to rank-1 arrays of integers.
In my post to the fitting factors thread in the Forums, you may see a concrete example of where the new inverse would be more succinct: I had to write &.(q:"1) rather than the shorter &.q:.
Like any other change, backwards compatibility must be considered, but I don't imagine this would break much code.
-- DanBron 2008-01-08 21:48:26
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.
-- BJonas 2008-02-01 08:10:35
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. . -- RogerHui 2008-02-01 15:20:08
make dyad ". invertible
I request that the dyad ". (numbers) be given an inverse. I propose the inverse be ": (as it is for monadic ".). A minor improvement would be to to use a hypen rather than an underbar for the negative sign.
I can't of a way to make the x in x&". useful to the inverse. One idea is to make x&".^:_1 ↔ x&":, but the problem with that approach is that for most applications, x=0, yet 0&": is not a useful format (again, for most applications).
In any case, I see no reason why +:&(0&".) should fail (and its obvious substitute, +:&.". has wrong (and dangerous) semantics.
-- DanBron 2008-02-01 23:27:07
make tacit scalar replacement invertible
I request that the idiomatic verb =&m`(,:&n) } for scalar m and n, be invertible. The inverse is =&n`(,:&m) } .
For example:
in =. =&'-'`(,:&'_') } out =. =&'_'`(,:&'-') } io =. [: ". in :. out +:&.io '-1 2 3' -2 4 6
could be rewritten more succinctly as:
io =. [: ". '-'&=`(,:&'_') }
+:&.io '-1 2 3'
-2 4 6This one new inverse would suffice for the majority of my use cases, but you may also consider making inverses for the verb's affilates.
That is, you could create the following mappings (or a subset thereof):
= &m`(,:&n) } ^:_1 ↔ = &n`(,:&m) } NB. A ~:&m`(n&,:) } ^:_1 ↔ ~:&n`(m&,:) } NB. B m& =`(,:&n) } ^:_1 ↔ n& =`(,:&m) } NB. C m&~:`(n&,:) } ^:_1 ↔ n&~:`(m&,:) } NB. D = &m`(n&,:) } ^:_1 ↔ = &n`(m&,:) } NB. E ~:&m`(,:&n) } ^:_1 ↔ ~:&m`(,:&m) } NB. F m& =`(n&,:) } ^:_1 ↔ n& =`(m&,:) } NB. G m&~:`(,:&n) } ^:_1 ↔ n&~:`(,:&m) } NB. H
But I'm not convinced these extra inverses provide much value:
- Mappings E-H are going to see less use (it can be useful to say "replace everything that's not a FOO with a BAR, but it's not so useful to invert that function).
The form m&= is redundant with =&m. It's not so hard to write the latter if you want your function invertible.
A similar sentiment applies to ~:&m`(n&,:) vs =&m`(,:&n) .
-- DanBron 2008-02-01 23:45:30
special code for tacit scalar replacement
I request that the idiomatic verbs m&=`(,:&n)} and m&=`(n&,:)} for scalar m and n and e.&m`(,:&n)} and e.&m`(n&,:)} for vector m and scalar n be supported by special code.
In particular, I am thinking of the special code which underlies c}x,:y for boolean c (that is, the special code for explicit monadic boolean amendment).
If my proposed inverses for scalar replacement are implemented, I submit the parrallel request that this special code support those inverses as well (which may just fall out natually, as the inverses have the same (optimizable) form).
In that previous request, I showed how the = verbs can be useful. Here is an example of the utility of the e. verbs:
e.&WHITESPACE`(,:&' ')} 'stuff and',LF,'things',TAB,'some more'
stuff and things some more
e.&DIGITS `(' '&,:)} 'buy 123 of item 5'
123 5
;: e.&WHITESPACE`(,:&' ')} 'stuff and',LF,'things',TAB,'some more'
+-----+---+------+----+----+
|stuff|and|things|some|more|
+-----+---+------+----+----+
0 ". e.&DIGITS `(' '&,:)} 'buy 123 of item 5'
123 5-- DanBron 2008-02-02 00:29:14
redefine u;.0 y
Currently, the definition of monad cut-0 is (1224 143 qdoj ';.'):
u;.0 y applies u to y after reversing y along each axis; it is equivalent to (0 _1 */$y) u;.0 y
I don't think this definition is very useful. I propose u;.0 y be redefined to mean "apply u along each axis of y", or, formally:
u;.0 y ↔ 0&|:@:u^:(#@:$) y
Though backwards-incompatible, I believe the change is warranted. The question of "how do I apply a function to each axis of an array" arises perenially in the Forums. For example:
New inverse and Block Matrix Inverse (uses f"i for each axis i of its argument)
On the other hand, I do not see evidence that there is a frequent need to reverse an array along each axis. Further, code that does depend on the current definition of u;.0 y can readily be converted to use the new definition, simply by replacing u;.0 y with u |.;.0 y or (0 _1 */$y) u;.0 y or (-$y) u;.0 y; verb definitions that embed the monad u;.0 can be similarly converted by substituting @:(|.;.0) for ;.0.
As these substitutions show, the new definition is a generalization of the old, and is more in the spirit of ;. (in particular, and J in general).
-- DanBron 2008-06-20 19:24:51
I solicited comments on this proposal from members of the Forum.
Expand 15!: in the Dictionary
The dictionary page for the 15!: foreign (native function call interface) is currently only a list that names the first few 15!: functions. It links to a User page that gives some more information. Even if the 15!: foreign isn't documented in the dictionary as completely as most other foreigns, it would be nice if at least all of its subfunctions would be listed. Specifically 15!:10 (get error code) is documented in User, and the module gives names to other verbs as well: 15!:5 (unload shared libary), 15!:6, 15!:7, 15!:8, 15!:9, 15!:11, 15!:13. -- BJonas 2008-08-06 13:55:57 (I forgot to add this was dictionary for j602 on x86 linux system. -- BJonas 2008-08-06 14:01:52)
Change ;: dyad
I would like to propose two changes for the ;: dyad.
- We should be able to represent next state and output code as a single number. Instead of 2 3 for state 2, output code 3, we should be able to use 2.3.
- We should be able to request trace columns without having to represent all of them.
My motivation in both cases is compactness and efficiency. Of course, we have other ways of reaching these results. We could, for example, re-implement ;: in J. However, ;: is useful because of its compactness and efficiency. The benefits would be visual, as well as mechanical (especially on 64 bit systems). I have attached a proposed update to the dictionary proposed-d332.htm. -- Raul Miller 2009-06-03 19:33:10
extend Cut
I'd like to propose two extensions for the Cut (;.) dyad.
Some partitioned algorithms require to have position of non-complete shard at the begin of array. Current u;.3 and u;._3 implementation provides that shard at the end of array only. Following is the model of extension desired ("5" is selected randomly for example only):
(4 ,: 3) <;.5 (i. 10) ┌───┬─────┬─────┐ │0 1│2 3 4│6 7 8│ └───┴─────┴─────┘
Sometimes there is a need to align selected shard within frame not to the left (beginning) of the frame as currently implemented, but to the right (end), too:
(_4 ,: 3) <;.3 (i. 10) ┌─────┬─────┬───┐ │1 2 3│5 6 7│8 9│ └─────┴─────┴───┘ (_4 ,: 3) <;.5 (i. 10) ┌───┬─────┬─────┐ │0 1│3 4 5│7 8 9│ └───┴─────┴─────┘
-- Igor Zhuravlov 2009-12-26 16:55:18
extend Evoke Gerund
I'd like to propose the extension for the Evoke Gerund (`:) conjunction, described on page Extended forks. Following is example of such extension usage, e.g. for 3-fork ("9" is selected randomly for example only):
NB. proposed evoke by extended Evoke Gerund (`:) functionality 2 (+`%:`-`%`^`*`:9) 4 0.00379719j0.00219231 NB. evoke using the model adverb from script supplied with page 'Extended forks' 2 (+`%:`-`%`^`* fork3) 4 0.00379719j0.00219231
In gerund, Cap ([:) (at leftmost position in execution tree) and Self-Reference ($:) verbs support is desirable.
-- Igor Zhuravlov 2009-12-26 19:30:00
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.
-- BJonas 2010-02-21 23:24:37
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).
-- DanBron 2010-02-22 15:21:23
- 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! :-) -- BJonas 2010-02-22 22:18:38
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!.0Where names starting with PRIM_ are defined by my primitive classes utility, and qdoj and html are defined by my dictionary quoting utility.
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 specifies fill).
-- DanBron 2010-02-24 18:02:28
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 #).
-- DanBron 2010-02-25 13:06:09
- Wait. Does key-fit really work like that, setting the global tolerance setting temporarily?
extend fit conjunction
This would allow overtake on a boxed array to supply the fill (boxed) element suitable for further processing.
In dictionary format -
Fit(Customize) u !. v The case of !. with a verb right argument is defined in terms of the noun right argument case (u !. n) as follows: x u !. v y <--> x u!.(x v y) y u !. v y <--> u!.( v y) y
and
Fit(Customize) u !. n This conjunction modifies certain verbs in ways prescribed in their definitions. Case n is not a gerund, ...(same as current definition ) Case n is a gerund. (Compare with the gerund cases of the merge adverb } and power conjunction ^: ) x u!.(v0`v1`v2) y <--> (x v0 y) u!.(x v1 y) (x v2 y) x u!.( v1`v2) y <--> x u!.([`v1`v2) y u!.( v1`v2) y <--> u!.(v1 y) (v2 y)
Because a gerund is a boxed noun there may be an issue with the second case. It may be the case that a gerund may be a valid fill (or other customisation) element so that fit evoking the gerund would not be possible.
However having a verb right argument for the fit conjunction seems possible. The verb could inspect both x and y to determine an appropriate fill element.
-- Ian Shannon 2010-07-28 09:36:30
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.
-- BJonas 2010-08-25 22:12:53
Allow proverbs that are temporarily invalid to be created from atomic form
From experimenting with j701 on x86 linux, it seems that if the value of a name is currently a noun (or adverb or conjunction), then you cannot create a proverb referring to that name even by evoking that proverb from its atomic representation. Eg., if the value of a is 99, then b=:(<'a')@.0 or b=:(<'/';<<'a')@.0 gives an error. The case is similar with a name that is an indirect locative that currently refers to a nonexistent or invalid locale, eg. you cannot evoke <'a__b' if b has no value or has a value that is not a valid boxed locale name. I'd like to ask you to change this behaviour and allow such an atomic form to be evoked to a verb.
A proverb referring to such a name can exist, if it was created earlier when it was valid, and can become valid and callable later. If the change I suggest is made to the interpreter, you could evoke such a potentially valid proverb any time by evoking it from its atomic representation, and it would behave just as if you had created it an earlier time, that is, it could become callable later, or raise an error if called (as a verb) before it becomes valid. It's natural that you still shan't be able to create such a proverb by the grammar while the name is invalid, for if the name points to a noun (or adverb or conjunction) when it's moved by the grammar, then it has to take its value instead of creating a proverb; and by analog if the name refers to an invalid locale then it does make sense to raise an error because there's no way to know whether it should be treated as a verb or a non-verb. (The same applies for creating a proverb with the ~ adverb instead of the grammar.)
There are multiple ways such a proverb can become valid: the current locale or its search path could change, bringing the intended name (or the referred name used as a locale) back into scope; the name (or the part) could cease to be shadowed by a local name, or be created as a local name; or simple the name can be reassigned a verb, or the second part assigned a locale value. In such a case, you might be able to call such a name again.
The reason why I don't like the current behavior is that it makes it possible to have a verb of which you take the atomic form and then evoke it from that form, you get an error. As far as I know, this is the only case when that can happen. It is useful to be able to store any verb (or noun or adverb or conjunction) in atomic form and then turn it back any time to get the same thing, and it does usually work. I'd like to think that a program can rely on that it always work. An example where this could be useful is when you have a program like jevalbot that saves the state of the interpreter by atomizing (with 5!:1) and serializing (with 3!:0) the value of every name and export it, and later reload that state to another interpreter instance. This could thus fail if some name referred to a verb that contained inside an indirect locative proverb, which uses as its locale reference another name that would only be filled out later (you can't except the program to know which order to reload these names).
-- BJonas 2010-08-25 22:49:31
Allow @ with noun right argument
currently verb @ noun gives domain error. I suggest it to have meaning verb @ (noun"_) same way as N V V fork was extended
-- AndrewNikitin 2010-08-29 04:38:02
