Very much enjoyed your presentation. You make a good case for fixed tacit
code, though you neglected the most obvious argument: Just as you would not
want to use global data variables for "every thing", it follows that relying on
as few external names as possible reduces the complications that occur when
those names are changed or no longer present.
With that said, there is a simpler approach to turning adverbs like amend into
a verb( and so usable in tacit expressions):
itmemamend =: 4 : 'x}y'
there are also enhancement as to rank that can replace the simpler case above:
itemamend2 =: (([: ;/(,.i.@#))@:[ { ])"1 _
itemamend =: 4 : '((2}.$y) $"1 0 x)} y'
----- Original Message -----
From: Jose Mario Quintana <[email protected]>
To: Programming forum <[email protected]>
Cc:
Sent: Tuesday, July 22, 2014 12:39:33 PM
Subject: Re: [Jprogramming] Tacit J and indexed replacement
Don wrote:
"I think it would be impossible to do an amendment in place in tacit code"
It is not possible to amend in place tacitly in the official version of J.
However, tacit versions of amend, and append, in-place have been
implemented in an special version of J. These are definitively not for the
faint of heart because the tacit writer has to assume full responsibility
and unexpected consequences might (will eventually) happen.
The following is a comparison between a tacit implementation of a Turing
machine (utm) (for details, see the link of my talk in
http://www.jsoftware.com/jwiki/Community/Conference2012#Schedule) and an (a
partial) in-place (utmIP) version where only the sentence,
T h( amend o (PRINT f ; P f ; T f ) ) f.
<@:((0: 0&({::)@:]`(<@:(1&({::))@:])`(2&({::)@:])} ])@:(7&({::) ; 3&({::) ;
2&({::))) 2} ]
in the utm was replaced by,
(PRINT,P,T) Amend
7 3 2&(102!:0)
in the utmIP; the array (the tape referred by T) grows to a maximum tally
of just 1965 in this example, nevertheless, the in-place amendment makes a
difference (Surface 2 Pro timings running on battery):
st
(] , <@:(1&({::) * 2&({::)))@:(] ; 7!:2@:] ; 6!:2)
NB. http://www.drb.insel.de/~heiner/BB/bb-list (similar to Uhing's)
NB. 0 1 Tape Symbol Scan
NB. S p m g p m g
QS=. (noun _) ; 0 NB. Reading the transition table and setting the state
0 1 _1 1 1 _1 3
1 1 1 2 0 1 4
2 0 _1 0 0 1 1
3 1 _1 4 1 0 _1
4 1 1 2 1 _1 2
)
TPF=. 0 ; 0 ; _ NB. Setting the tape, its
pointer and the display frequency
st'TPF smoutput@:utm QS NB. (not in-place)'
0 0:0
0 :^
3 1
:11010101010101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111...
2358064:^
...
0 0:0
0 :^
3 1
:11010101010101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111...
2358064:^
...
┌─────────────────────────────────────────┬──────┬──────────┬──────────┐
│TPF smoutput@:utm QS NB. (not in-place)│219648│78.6351039│17272043.3│
└─────────────────────────────────────────┴──────┴──────────┴──────────┘
st'TPF smoutput@:utmIP QS NB. (in-place)'
0 0:0
0 :^
3 1
:11010101010101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111...
2358064:^
...
0 0:0
0 :^
3 1
:11010101010101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111011101110111...
2358064:^
...
┌─────────────────────────────────────┬──────┬──────────┬──────────┐
│TPF smoutput@:utmIP QS NB. (in-place)│216064│62.9319836│13597336.1│
└─────────────────────────────────────┴──────┴──────────┴──────────┘
On Tue, Jul 8, 2014 at 6:28 PM, Don Guinn <[email protected]> wrote:
> I think it would be impossible to do an amendment in place in tacit code,
> but amendment should still work in a tacit expression, just not in place.
> But if the result were assigned back to the original variable what will
> happen? Would the tacit expression prevent it from recognizing the
> operation as an amendment in place?
>
>
> On Tue, Jul 8, 2014 at 4:21 PM, Jose Mario Quintana <
> [email protected]> wrote:
>
> > Erling wrote: "It's obviously not possible to do any amendments in tacit
> > code?" Adding after wards: "A principle of functional programming is you
> > never modify a variable?"
> >
> >
> >
> > From my perspective those (rhetorical?) questions are separate.
> Regarding
> > the first question, consider the verb (v) that produces the squares of an
> > amendment produced by the verb amend. For example,
> >
> >
> >
> > ( v=. *: @: amend f. )
> >
> > *:@:(_: 0&({::)@]`(1&({::)@])`(2&({::)@])} ])
> >
> >
> >
> > v (0 1 2 ; 2 3 5 ; 7#9)
> >
> > 81 81 0 1 81 4 81
> >
> >
> >
> > The verb (v) is tacitly defined (is it not?) and amendment is performed
> via
> > } (is it not?); thus the answer to the first question is that it is
> > possible. Furthermore, the conclusion is reached regardless of what the
> > meanings of “functional programming” and “variable” might, or might not,
> > be. (Am I missing something?).
>
> ----------------------------------------------------------------------
> 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