> 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.


On Wed, Jan 23, 2019 at 9:31 AM R.E. Boss <[email protected]> wrote:

> Thanks Brian, I'm pleased to hear you enjoyed it.
>
> Well, one can argue whether an explicit verb is a one-liner or not.
> 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?
>
> BTW, it is more than a couple of years ago C. did not have an obverse.
>
>
> R.E. Boss
>
>
> > -----Oorspronkelijk bericht-----
> > Van: Programming <[email protected]>
> > Namens Brian Schott
> > Verzonden: woensdag 23 januari 2019 14:47
> > Aan: Programming forum <[email protected]>
> > Onderwerp: Re: [Jprogramming] Sorting on two keys
> >
> > RE,
> >
> > Previously I learned via your code a use of C. that was eye-opening.
> > This time, I learned via your code how a multi-x can be used in a one
> liner.
> >
> > Very good.
> >
> > On Wed, Jan 23, 2019 at 5:45 AM R.E. Boss <[email protected]> wrote:
> >
> > > If your x variable denotes the columns to be sorted plus the way in
> > > which that should be done, like
> > > 0 3 2 1,:_1 1 _1 1
> > > Then the (explicit) toolbox verb could be
> > >
> > > foo=:4 : ('''x1 x2''=.x' ; 'x2([/: *"1)&.:(x1&C."1)~ y')
> > >
> > >    a ,.@;~&|:   (0 3 2 1,:_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 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2|
> > > |0 0 0 2 2 2 1 1 1 0 0 0 2 2 2 1 1 1 0 0 0 2 2 2 1 1 1 0 0 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|
> > > +-----------------------------------------------------------+
> > > |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|
> > > |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 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|
> > > |0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2|
> > > +-----------------------------------------------------------+
> > >
> > >
> > > R.E. Boss
>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to