“It breaks my heart to replace all the Caps with Ats!

You change a nice right to left tacit expression back to a left to right
parenthesized expression.”
Linda, I meant no harm :) but I read and write lines left to right. From my
vantage point [: has dual personalities: a whistle-blower and a teaser; I
am fine with the former but I cannot stand the latter. Moreover, too many
teasers can hide a whistle-blower as in your “too many caps” illustration:

   ',{:+ [: {:}:y'(13 : )
[: , [: {: [: + [: [: [: {: }:
In the good old days, from my perspective, @: was used instead of [: and
the whistle-blower would have been as visible in the tacit as it is in the
explicit expression.

“Once you found a tacit expression for a block, wouldn't you use it in next
definition?

' }. (<:0{x) |. y' (13 :) NB. Finding a tacit form for the for block...
[: }. ] |.~ [: <: 0 { [“

I read the last line more or less as follows: trigger a domain error, just
kidding; forget the usual fork interpretation, make the middle verb to act
monadic-ally on the ending verb; so, drop the... trigger a domain error,
just kidding; forget the usual fork interpretation, make the middle verb to
act monadic-ally on the ending verb; so, decrement the first item on the
left (argument).

I always get rid of the distracting teasers; I tried to use them for a
while but I gave up. Personally, I like simplicity and consistency and I
have not found any compelling reason to keep any teaser in any context.





On Sat, May 11, 2013 at 2:58 AM, Linda Alvord <[email protected]>wrote:

> Maybe this illustrates where "too many caps" comes from.
>
>    ',{:+ [: {:}:y'(13 : )
> [: , [: {: [: + [: [: [: {: }:
>
> It breaks my heart to replace all the Caps with Ats!
>
> You change a nice right to left tacit expression back to a left to right
> parenthesized expression.
>
> Is it possible to improve on how the expression above inserts the Caps?
>
> Linda
>
> -----Original Message-----
> From: [email protected] [mailto:
> [email protected]] On Behalf Of Jose Mario Quintana
> Sent: Thursday, May 09, 2013 6:26 PM
> To: [email protected]
> Subject: Re: [Jprogramming] rosettacode
>
> Skip, I finally was able to take a look at your version.  The following
> should be a series of equivalent definitions of your version. I do not code
> explicitly thus the control words are alien to me but they probably are
> correct:
>
>    jose1=: 4 : 0
>  k =. y - 1{x            NB. k is the number of "kills"
>  L =. i. y               NB. L is the position list
>  whilst. k =. k-1 do.
>      L =. (<:0{x) |. L   NB. Rotate by the skip number
>      L =. }. L           NB. Remove the dead index.
>  end.
> )
>
> Substituting L in the first line of the whilst block into the second line,
>
>    jose10=: 4 : 0
>   k =. y - 1{x           NB. k is the number of "kills"
>   L =. i. y              NB. L is the position list
>   whilst. k =. k-1 do.
>     L =. }. (<:0{x) |. L NB. Removing the dead index after rotating by the
> skip number
>   end.
> )
>
> Replacing the whilst by a for form,
>
>    jose11=: 4 : 0
>   k =. y - 1{x           NB. k is the number of "kills"
>   L =. i. y              NB. L is the position list
>   for. i.k do.
>     L =. }. (<:0{x) |. L NB. Removing the dead index after rotating by the
> skip number
>   end.
> )
>
> Eliminating L by reusing y,
>
>    jose12=: 4 : 0
>   k =. y - 1{x           NB. k is the number of "kills"
>   y =. i. y              NB. L is the position list
>   for. i.k do.
>     y =. }. (<:0{x) |. y NB. Removing the dead index after rotating by the
> skip number
>   end.
> )
>
> Finding a tacit form for the for block...
>
>    '}. (<:0{x) |. y' (13 :)
> [: }. ] |.~ [: <: 0 { [
>
> Replacing Caps by Ats because Caps are overused! ;)
>
>    }.@:(] |.~ <:@:(0 { [))
> }.@:(] |.~ <:@:(0 { [))
>
> Replacing the for form by a power form,
>
>    jose13=: 4 : 0
>   k =. y - 1{x
>   y =. i. y
>   x (}.@:(] |.~ <:@:(0 { [))) ^: k y
> )
>
> Making a one-liner by substituting k and y in the first and second lines
> into the code of the last line,
>
>    jose14=: 'x (}.@:(] |.~ <:@:(0 { [)))^:(y - 1{x) i. y' (4 :)
>
> Trying to find a tacit expression,
>
>    'x (}.@:(] |.~ <:@:(0 { [)))^:(y - 1{x) i. y' (13 :)
> 4 : 'x (}.@:(] |.~ <:@:(0 { [)))^:(y - 1{x) i. y'
>
> No, J is not smart enough; not yet anyway.  Replacing (y - 1{x) by __ to
> find the form,
>
>    'x (}.@:(] |.~ <:@:(0 { [)))^:__ i. y' (13 :) [ }.@:(] |.~ <:@:(0 {
> [))^:__ [: i. ]
>
> Replacing the offending Cap,
>
>    [ (}.@:(] |.~ <:@:(0 { [))^:__) i.@]
> [ }.@:(] |.~ <:@:(0 { [))^:__ i.@]
>
> Consulting the Dictionary for power... Yes, the gerund form fits the bill!
>
>    jose15=. }.@:(] |.~ <:@:(0 { [))^:((] - 1 { [)`(i.@]))
>
>    3 7 (jose1 ; jose15) 10000
> ┌────────────────────────────────┬────────────────────────────────┐
> │8922 111 930 2691 3850 6154 6624│8922 111 930 2691 3850 6154 6624│
> └────────────────────────────────┴────────────────────────────────┘
>
> They compare as follows,
>
>    st=. 7!:2@:] ; 6!:2
>
>    10 st '3 7 jose1  10000'
> ┌──────┬────────┐
> │133440│0.100217│
> └──────┴────────┘
>    10 st '3 7 jose15 10000'
> ┌──────┬────────┐
> │263808│0.184226│
> └──────┴────────┘
>
> The explicit version is leaner and faster but my attitude is to wait for
> the implementation to catch up (I would not bet on it though).  Wait!
> Apparently the issue is more complicated than just explicit versus tacit,
>
>    ((<10) (((,@<@]) , st) &> ) (('3 7 ' , ] , ' 10000'"_)each @: ;:))
> 'jose1 jose10 jose11 jose12 jose13 jose14 jose15'
> ┌────────────────┬──────┬────────┐
> │3 7 jose1 10000 │133440│0.100398│
> ├────────────────┼──────┼────────┤
> │3 7 jose10 10000│199104│0.183993│
> ├────────────────┼──────┼────────┤
> │3 7 jose11 10000│265152│0.174459│
> ├────────────────┼──────┼────────┤
> │3 7 jose12 10000│265152│0.173494│
> ├────────────────┼──────┼────────┤
> │3 7 jose13 10000│265728│0.181894│
> ├────────────────┼──────┼────────┤
> │3 7 jose14 10000│265920│0.180529│
> ├────────────────┼──────┼────────┤
> │3 7 jose15 10000│263808│0.180721│
> └────────────────┴──────┴────────┘
>
> This is puzzling to me; then again, I do not know much (to say the least)
> about the performance of explicit code.
>
>
>
>
> On Sat, May 4, 2013 at 1:42 AM, Skip Cave <[email protected]> wrote:
>
> > Very nice Elton and Jose! I had a bug in my explicit formula, as well
> > as having some extra variables I didn't need. So I simplified my
> > formula and changed the index to the "Mayan Way" (zero index).
> >
> > jose1=: 4 : 0
> > k =. y - 1{x       NB. k is the number of "kills"
> > L =. i. y           NB. L is the position list
> > whilst. k =. k-1 do.
> >     L =. (<:0{x) |. L    NB. Rotate by the skip number
> >     L =. }. L      NB.  Remove the dead index.
> > end.
> > )
> >
> > So now my results match Jose and Elton's tacit versions.
> >
> >    3 4 jose1 20
> > 19 1 7 12
> >
> >    5 1 jose1 200
> > 112
> >
> >    7 10 jose1 345
> > 283 287 295 319 72 92 93 137 175 224
> >
> > Interestingly:
> >
> >    Ts '7 10 jose1 345'
> > 0.0028602 6464
> >
> >    Ts '7 10 jose 345'
> > 0.0010386 65664
> >
> >    Ts '3 7 jose1 10000'
> > 0.0823621 133440
> >
> >    Ts '3 7 jose 10000'
> > |stack error: jose
> > |   3 7     jose 10000
> >
> > Where jose1 is my explicit version, and jose is Elton's tacit version.
> >
> > Elton, I'm trying to parse through your tacit version to understand
> > how it works. Could you break it appart, and explain what is going on in
> there?
> >
> > Is it possible to implement my explicit algorithm in a tacit
> > expression that won't get a stack error with large numbers?
> >
> > Skip
> >
> >
> > On Fri, May 3, 2013 at 7:13 PM, elton wang <[email protected]> wrote:
> >
> > > modified from Jose's recursive form:
> > >
> > > jose =. i.@{:@[`(] | {.@[ + [ $: _1 + ])@.({:@[ < ])
> > >
> > >
> > --
> > Skip Cave
> > Cave Consulting LLC
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to