Your solution is beyond my capacity to comprehend, or to appreciate.

My explicit verb could easily be turned in a one-liner by 
foo=: 4 :  '({:x)([/: *"1)&.:(({.x)&C."1)~ y'
   |:(0 3 1 2,:_1 1 _1 1) foo a=.3#.^:_1 i.30
1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 1 1 2 2 2 0 0 0 1 1 1 2 2 2 0 0 0 1 1 1 2 2 2
0 0 0 2 1 0 2 1 0 2 1 0 2 1 0 2 1 0 2 1 0 2 1 0 2 1 0 2 1 0
0 1 2 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2

I decided to test my craftmanship on tacitness and, after quite some thinking, 
came up with 
foo_tct=: ([ ({.@[, {:@[(]/: *"1 ) }.@]) &.:(({., {.C."1 }.) :. ({.C.^:(_1)"1 
}.)) (,~{.)~)

   (0 3 1 2,:_1 1 _1 1) (foo-: foo_tct) a
1

Once more I was remembered to the fact that in the under construction, u&.v and 
u&.:v , v and its inverse are always applied monadically, v to the left and 
right parameters, and its inverse to the result of u.
For that reason I had to add the first item at the left to the noun at the 
right.
The inverse I also had to define properly.


R.E. Boss


> -----Oorspronkelijk bericht-----
> Van: Programming <[email protected]>
> Namens Jose Mario Quintana
> Verzonden: donderdag 24 januari 2019 00:11
> Aan: Programming forum <[email protected]>
> Onderwerp: Re: [Jprogramming] Sorting on two keys
> 
> > Well, one can argue whether an explicit verb is a one-liner or not.
> 
> 
> Right, foo is not displayed as a one-liner,
> 
>    foo
> 4 : 0
> 'x1 x2'=.x
> x2([/: *"1)&.:(x1&C."1)~ y
> )
> 
> as opossed to,
> 
>    ( goo=. 4 : 'x2([/: *"1)&.:(x1&C."1)~ y [ ''x1 x2''=.x ' )
> 4 : 'x2([/: *"1)&.:(x1&C."1)~ y [ ''x1 x2''=.x '
> 
> > At least it was too much work for me to fiddle out how to write this
> tacitly. We have high priests for that, haven't we?
> 
> 
> Alas, no high priest has shown up yet.  It seems to be too much work for me
> as well; particularly, because I regard myself as a lazy heretic anyway.
> Nevertheless, sometimes I spend some time thinking about certain things to
> avoid spending time thinking about certain things anymore.  If I had to have a
> tacit version of foo, I probably would employ (;) instead of (,:) as a 
> delimiter
> and use the following wicked version,
> 
> ". noun define -. CRLF
> 
> hoo=.
> 
> ((<<9 0
> 13),(<(<'X2'),(<,'('),(<,'['),(<'/:'),(<,'*'),(<,'"'),(<<(,'0');1),(<
> ,')'),(<'&.:'),(<'X1'),(<,'&'),(<'C.'),(<,'~'),<,'Y'),<(<0),(<2;3;4;5;6),(<8)
> ,(<9;10;11;5;6),(<12),<13)&((1&({::) ,^:(0:`(<'@.')) 2&({::))@:(<@:((0:
> 0&({::)@:]
> `(<@:(1&({::)@:]))`(2&({::)@:])} ])@:(3 0 1&{)) 1} ])@:(((#@:(1&({::)) ~:
> >@:
> (0&({::))) (([ # 3&({::)@:]) ,&:< [ <@:# >@:(0&({::))@:]) ]) 3 0} ])@:(, <))@
> :(<@:((,'0') ,&:< ])&.>)@:([ , <@:])
> 
> 
> )
> 
> Yes, it is displayed as a pretty long one-liner (admitedly, "a pretty long 
> one-
> liner" is, in some sense, an oxymoron),
> 
>    hoo
> ((<<9 0
> 13),(<(<'X2'),(<,'('),(<,'['),(<'/:'),(<,'*'),(<,'"'),(<<(,'0');1),(<,')'),(<'&.:'),(<'X1'),(
> <,'&'),(<'C.'),(<,'~'),<,'Y'),<(<0),(<2;3;4;5;6),(<8),(<9;10;11;5;6),(<12),<13)&((1
> &({::)
> ,^:(0:`@.) 2&({::))@:(<@:((0: 0&({::)@:]`(<@:(1&({::)@:]))`(2&({:...
> 
> and it is obfuscated vs foo and goo; yet, its relative performance does not
> seem to be too bad,
> 
>    ". noun define -. CRLF
> 
> stp=.
> 
> ] (([ ((<;._1 '|Sentence|Space|Time|Space * Time') , (, */&.:>@:(1 2&{))@:(]
> ; 7!:2@:] ; 6!:2)&>) (10{a.) -.&a:@:(<;._2@,~) ]) [ (0 0 $ 13!:8^:((0 e.
> ])`(
> 12"_)))@:(2 -:/\ ])@:(".&.>)@:((10{a.) -.&a:@:(<;._2@,~) ]) ::(0
> 0&$@(1!:2&2)
> @:('Mismatch!'"_))) ".@:('0( : 0)'"_)
> 
> 
> )
> 
> (Note that both, foo and goo, can also take (;) as a delimiter.)
> 
>    A=. 3#.^:_1 i.30
> 
>    stp 666
> 
> (0 3 2 1,:_1 1 _1 1) foo A
> (0 3 2 1,:_1 1 _1 1) goo A
> 
> (0 3 2 1; _1 1 _1 1) foo A
> (0 3 2 1; _1 1 _1 1) goo A
> (0 3 2 1; _1 1 _1 1) hoo A
> 
> )
> ┌──────────────────────────┬─────┬──────────┬────────────
> ┐
> │Sentence                  │Space│Time      │Space * Time│
> ├──────────────────────────┼─────┼──────────┼────────────
> ┤
> │(0 3 2 1,:_1 1 _1 1) foo A│17792│5.16206e_5│0.918433    │
> ├──────────────────────────┼─────┼──────────┼────────────
> ┤
> │(0 3 2 1,:_1 1 _1 1) goo A│18560│4.95953e_5│0.920488    │
> ├──────────────────────────┼─────┼──────────┼────────────
> ┤
> │(0 3 2 1; _1 1 _1 1) foo A│17024│4.83655e_5│0.823374    │
> ├──────────────────────────┼─────┼──────────┼────────────
> ┤
> │(0 3 2 1; _1 1 _1 1) goo A│17792│4.92424e_5│0.876121    │
> ├──────────────────────────┼─────┼──────────┼────────────
> ┤
> │(0 3 2 1; _1 1 _1 1) hoo A│20864│6.20376e_5│1.29435     │
> └──────────────────────────┴─────┴──────────┴────────────
> ┘
> 
>    JVERSION
> Engine: j807/j64nonavx/windows
> Release-a: commercial/2019-01-11T11:13:30
> Library: 8.06.09
> Qt IDE: 1.6.2/5.6.3
> Platform: Win 64
> Installer: J806 install
> InstallPath: j:/program files/j
> Contact: www.jsoftware.com
> 
> Of course, I did not write hoo directly; instead, I just wrote the less 
> cryptic (to
> me anyway),
> 
>    erase'X1 X2 Y'  NB. (just in case)
> 
>    hoo=. [: X1 X2 Y 'X2([/: *"1)&.:(X1&C."1)~ Y' xi o ([ , <y)
> 
> after running the J Wicked Toolkit and I amended its faulty linear
> representation to repair the damage caused by the resistant bug,
> 
>    ^:(0:`(<'@.'))
> ^:(0:`@.)
> 
> (Beware, wicked entities run on j807; but, I am afraid, their days might be
> counted.)
> 
> PS.  I am sure a willing high priest can write a neat orthodox tacit version
> instead.
> 
> 

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

Reply via email to