Hi all !
I do my best to understand this. Like Raul I name things. I created some
explanations. However, I didn't manage to understand how a3 and a6
works. Maybe someone can help?
My project:
9!:14''
o=: @:
ar=: 5!:1 @:<
ar 'o'
emptyGerund=: `''
emptyGerund
DoOnLeftArgAdverb=: (@:[) ((<'&')`) (`:6)
+/ DoOnLeftArgAdverb
InfinityAdverb=: (`(<(":0);_)) (`:6)
%InfinityAdverb
ExecuteDoOnLeftArgAdverbWithLeftArg=: ((ar'emptyGerund')`)
(`(ar'DoOnLeftArgAdverb')) (`(ar'InfinityAdverb') ) (`:6)
1 2 3 *: ExecuteDoOnLeftArgAdverbWithLeftArg
FetchAtomicRepr=: < o ((0;1;0)&{::) NB. Fetching the atomic representation
br=: 5!:2@:<
f=: -@:-@-
br 'f'
FetchAtomicRepr br 'f'
a3=: (@: (FetchAtomicRepr f.)) ('ExecuteDoOnLeftArgAdverbWithLeftArg' f.)
RankInfinity=: "_
+RankInfinity
EvokeGerundTrain=: `:6
(+/)`%`# EvokeGerundTrain 1 2 3
a6=: ((( ar'RankInfinity') ; ] ; ( ar'a3')"_)
('ExecuteDoOnLeftArgAdverbWithLeftArg'f.)) (`:6)
hg=: `((ar'a6')`(ar'EvokeGerundTrain')) (`:6)
1 2 3 ((<'*:') ; ]) hg
an=: <@:((,'0') (,&<) ]) NB. Atomizing words (monadic verb)
an +`-`*`%
AdverbToPackvuGerundWithAt=:< o ((('@:') ; < o |.)) o (('';1)&{::) hg
(-`<) AdverbToPackvuGerundWithAt
3 (-`<) AdverbToPackvuGerundWithAt 2
AdverbToPackReverseOrderGerundWithAt=: ([ , (<'@:') , ])/o |. o
(('';1)&{::)hg
*:`-`%`+: AdverbToPackReverseOrderGerundWithAt
*:`-`%`+: AdverbToPackReverseOrderGerundWithAt 5
ConjunctionToExecuteVWithArgumentU=: ((an f.hg) (` (|. o
((('';1)&{::))hg)) (an f.hg))
1 2 3 ConjunctionToExecuteVWithArgumentU (+/)
The printout:
9!:14''
j806/j64/windows/beta/BEST/Jx-patches/2017-10-06T14:44:47
o=: @:
ar=: 5!:1 @:<
ar 'o'
┌──┐
│@:│
└──┘
emptyGerund=: `''
emptyGerund
`''
DoOnLeftArgAdverb=: (@:[) ((<'&')`) (`:6)
+/ DoOnLeftArgAdverb
&(+/@:[)
InfinityAdverb=: (`(<(":0);_)) (`:6)
%InfinityAdverb
0
ExecuteDoOnLeftArgAdverbWithLeftArg=: ((ar'emptyGerund')`)
(`(ar'DoOnLeftArgAdverb')) (`(ar'InfinityAdverb') ) (`:6)
1 2 3 *: ExecuteDoOnLeftArgAdverbWithLeftArg
1 4 9
FetchAtomicRepr=: < o ((0;1;0)&{::) NB. Fetching the atomic
representation
br=: 5!:2@:<
f=: -@:-@-
br 'f'
┌────────┬─┬─┐
│┌─┬──┬─┐│@│-│
││-│@:│-││ │ │
│└─┴──┴─┘│ │ │
└────────┴─┴─┘
FetchAtomicRepr br 'f'
┌─┐
│@│
└─┘
a3=: (@: (FetchAtomicRepr f.))
('ExecuteDoOnLeftArgAdverbWithLeftArg' f.)
RankInfinity=: "_
+RankInfinity
+"_
EvokeGerundTrain=: `:6
(+/)`%`# EvokeGerundTrain 1 2 3
2
a6=: ((( ar'RankInfinity') ; ] ; ( ar'a3')"_)
('ExecuteDoOnLeftArgAdverbWithLeftArg'f.)) (`:6)
hg=: `((ar'a6')`(ar'EvokeGerundTrain')) (`:6)
1 2 3 ((<'*:') ; ]) hg
1 4 9
an=: <@:((,'0') (,&<) ]) NB. Atomizing words (monadic verb)
an +`-`*`%
┌─────────────┐
│┌─┬─────────┐│
││0│┌─┬─┬─┬─┐││
││ ││+│-│*│%│││
││ │└─┴─┴─┴─┘││
│└─┴─────────┘│
└─────────────┘
AdverbToPackvuGerundWithAt=:< o ((('@:') ; < o |.)) o (('';1)&{::) hg
(-`<) AdverbToPackvuGerundWithAt
<@:-
3 (-`<) AdverbToPackvuGerundWithAt 2
┌─┐
│1│
└─┘
AdverbToPackReverseOrderGerundWithAt=: ([ , (<'@:') , ])/o |. o
(('';1)&{::)hg
*:`-`%`+: AdverbToPackReverseOrderGerundWithAt
+:@:%@:-@:*:
*:`-`%`+: AdverbToPackReverseOrderGerundWithAt 5
_0.08
ConjunctionToExecuteVWithArgumentU=: ((an f.hg) (` (|. o
((('';1)&{::))hg)) (an f.hg))
1 2 3 ConjunctionToExecuteVWithArgumentU (+/)
6
Cheers,
Erling Hellenäs
On 2017-10-21 21:52, Erling Hellenäs wrote:
My a2 name :)
InfinityAdverb=: (`(<(":0);_)) (`:6)
%InfinityAdverb
0
/Erling
On 2017-10-21 20:45, Raul Miller wrote:
Here's one issue:
1 2 3 *: av
1 4 9
load'debug/dissect'
dissect '1 2 3 *: av'
Syntax error: invalid sequence Noun Verb
Error snippet: 1 2 3 *: av
But that's not a syntax error.
And, for reference, here are two distinct implementations of av. First
an explicit approximation:
LR=: 5!:5@<
LRA=:1 :0
(LR 'u'),' m'
)
AV=:1 :0
1 :(u LRA)
)
Second, a restatement of Jose's code (but with a few different names):
ar=: 5!:1@:<
bGerund=: `''
Compose=: (@:[) ((<'&')`) (`:6)
a2=: (`(<(":0);_)) (`:6)
av=: ((ar'bGerund')`) (`(ar'Compose')) (`(ar'a2') ) (`:6)
I am still trying to think up a good name for a2 - roughly speaking
it's a placeholder which winds up being ignored in the result of the
Compose verb. I was interested in what dissect had to show me about
the evaluation process here, but that's not relevant to this problem,
which you can see by replacing av with AV.
#################################################
That said, it's perhaps also interesting that trace is also buggy:
trace '1 2 3 *: AV'
--------------- 5 Fork -------
1 2 3
*:
AV
1 2 3 *: AV
==============================
The problem seems to be an incomplete handling of locales. While trace
executes in the jtrace locale, the sentence it is executing comes from
a different locale (typically the base locale). This means that 4!:0
in movet treats AV as an undefined name (and, thus, a verb).
A quick and dirty fix would be to add
coinsert 'base'
to the top of addons/general/misc/trace.ijs (right under
cocurrent'jtrace').
This has two flaws but it's still better than nothing:
(1) it won't work when trying to trace in another locale,
(2) it will still shadow base names with jtrace names.
Problem 2 could be avoided by replacing uses of 4!:0 and ". with names
which are defined in the z locale (nc and do), and suffixing them with
locale references. Still not perfect (because relies on z), but
implementations which shadow z are already dubious.
I have no idea about problem 1 - maybe documentation would be the best
solution there. (Another possibility would be to add feature to the
locale support, to detect locale of the caller - but I can't think of
any non-obfuscation uses of that feature. And, yes, ... I guess I
might have to include "making jtrace automatically work regardless of
the current locale of the global session" as obfuscation. I am not
sure about that...)
#################################################
Anyways, since this is getting long, I have reported two problems here:
(1) An invalid "syntax error" in dissect
(2) A serious name resolution problem in trace
Thanks,
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm