Some fine points of interpreter use:
>:@i.@#
is the same as
#\
which still makes me giggle. And #\ is backed by special code so it's
faster too.
(;@:(<@(<\))~ >:@i.@#) 'abcdefg'
engages the special code for ;@:(<@f)) which avoids boxing overhead and
speeds up ; . All the parentheses are necessary for the fast form to be
recognized.
Henry Rich
On 10/24/2019 10:49 PM, Ric Sherlock wrote:
Tacit versions of my original
;@(>:@i.@# <@(<\) ]) 'abcdefg'
or if you like hooks:
;@(<@(<\)~ >:@i.@#) 'abcdefg'
On Fri, Oct 25, 2019 at 10:16 AM 'robert therriault' via Programming <
programm...@jsoftware.com> wrote:
Hey Skip,
My tacit equivalents, although not exactly equivalent since the tacit can
be extended to longer strings.
a#~-.(<'')=a=.,(>:i.5)<\'abcde' NB. Skip's version
┌─┬─┬─┬─┬─┬──┬──┬──┬──┬───┬───┬───┬────┬────┬─────┐
│a│b│c│d│e│ab│bc│cd│de│abc│bcd│cde│abcd│bcde│abcde│
└─┴─┴─┴─┴─┴──┴──┴──┴──┴───┴───┴───┴────┴────┴─────┘
((<'') -.~ ])@:(,@:((1+i.@:#)<\ ]))'abcde' NB. tacit version
┌─┬─┬─┬─┬─┬──┬──┬──┬──┬───┬───┬───┬────┬────┬─────┐
│a│b│c│d│e│ab│bc│cd│de│abc│bcd│cde│abcd│bcde│abcde│
└─┴─┴─┴─┴─┴──┴──┴──┴──┴───┴───┴───┴────┴────┴─────┘
((<'') -.~ ])@:(,@:((1+i.@:#)<\ ]))'abcdef' NB. six character string
example
┌─┬─┬─┬─┬─┬─┬──┬──┬──┬──┬──┬───┬───┬───┬───┬────┬────┬────┬─────┬─────┬──────┐
│a│b│c│d│e│f│ab│bc│cd│de│ef│abc│bcd│cde│def│abcd│bcde│cdef│abcde│bcdef│abcdef│
└─┴─┴─┴─┴─┴─┴──┴──┴──┴──┴──┴───┴───┴───┴───┴────┴────┴────┴─────┴─────┴──────┘
a: -.~ ,(>:i.5)<\'abcde' NB. Ric's version
┌─┬─┬─┬─┬─┬──┬──┬──┬──┬───┬───┬───┬────┬────┬─────┐
│a│b│c│d│e│ab│bc│cd│de│abc│bcd│cde│abcd│bcde│abcde│
└─┴─┴─┴─┴─┴──┴──┴──┴──┴───┴───┴───┴────┴────┴─────┘
(a: -.~ ,@:((>:@:i.@:#) <\ ]))'abcde' NB. tacit version
┌─┬─┬─┬─┬─┬──┬──┬──┬──┬───┬───┬───┬────┬────┬─────┐
│a│b│c│d│e│ab│bc│cd│de│abc│bcd│cde│abcd│bcde│abcde│
└─┴─┴─┴─┴─┴──┴──┴──┴──┴───┴───┴───┴────┴────┴─────┘
(a: -.~ ,@:((>:@:i.@:#) <\ ]))'abcdef' NB. six character string example
┌─┬─┬─┬─┬─┬─┬──┬──┬──┬──┬──┬───┬───┬───┬───┬────┬────┬────┬─────┬─────┬──────┐
│a│b│c│d│e│f│ab│bc│cd│de│ef│abc│bcd│cde│def│abcd│bcde│cdef│abcde│bcdef│abcdef│
└─┴─┴─┴─┴─┴─┴──┴──┴──┴──┴──┴───┴───┴───┴───┴────┴────┴────┴─────┴─────┴──────┘
Cheers, bob
On Oct 24, 2019, at 12:59 PM, Skip Cave <s...@caveconsulting.com> wrote:
I'm sure this can be reduced by J experts in implicit coding.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
--
This email has been checked for viruses by AVG.
https://www.avg.com
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm