Yes. I am not used to read this traces, but it seems to give the result I expected. It does not actually show that c is equivalent to @: and that the redundant calls to @: is what causes more memory to be allocated, but this is clearly the case? /Erling

On 2016-08-06 22:51, Brian Schott wrote:
I am not sure this is relevant to your questions, but in my J session below
I loaded the debug addon named "trace" and used it for two different
versions of your code. To run your version of the code which uses the
defined conjunction "c" I had to use "c__" in the trace because otherwise I
got a value error. But I think the result of trace may clarify the parsing
that J performs.



    c=: 2 :(':';'[: u v')
    (- c - c - c - )i. 4
0 1 2 3
    ([: - [: - [: - [: - ])i. 4
0 1 2 3
    2([: - [: - [: - [: - ])i. 4
0 1 2 3
    load'trace'
    trace'([: - [: - [: - [: - ])i. 4'
  --------------- 5 Trident ----
  [:
  -
  ]
  [: - ]
  --------------- 5 Trident ----
  [:
  -
  [: - ]
  [: - [: - ]
  --------------- 5 Trident ----
  [:
  -
  [: - [: - ]
  [: - [: - [: - ]
  --------------- 5 Trident ----
  [:
  -
  [: - [: - [: - ]
  [: - [: - [: - [: - ]
  --------------- 8 Paren ------
  (
  [: - [: - [: - [: - ]
  )
  [: - [: - [: - [: - ]
  --------------- 1 Monad ------
  i.
  4
  0 1 2 3
  --------------- 0 Monad ------
  [: - [: - [: - [: - ]
  0 1 2 3
  0 1 2 3
  ==============================
0 1 2 3
    trace'(- c__ - c__ - c__ - )i. 4'
  --------------- 4 Conj -------
  -
  2 : '[: u v'
  -
  [: - -
  --------------- 4 Conj -------
  [: - -
  2 : '[: u v'
  -
  [: ([: - -) -
  --------------- 4 Conj -------
  [: ([: - -) -
  2 : '[: u v'
  -
  [: ([: ([: - -) -) -
  --------------- 8 Paren ------
  (
  [: ([: ([: - -) -) -
  )
  [: ([: ([: - -) -) -
  --------------- 1 Monad ------
  i.
  4
  0 1 2 3
  --------------- 0 Monad ------
  [: ([: ([: - -) -) -
  0 1 2 3
  0 1 2 3
  ==============================
0 1 2 3



On Sat, Aug 6, 2016 at 4:02 PM, Erling Hellenäs <[email protected]>
wrote:

u1(u2(u3(u4(y)))) was the mathematical description of the strawman
algorithm. We are still in a discussion about tacit J. The expression you
are opposing is this one:


"As far as I can understand the pattern of the strawman, [: u1 [:u2 [: u3
[: u4 ] , is the only expression in tacit J with the meaning of 4  monadic
verbs ux in sequence. All other similar expressions have a more complex
meaning. Correct me if I'm wrong."

Bob Thierrault says:

I believe it could also be expressed as

u1 @: u2 @: u3 @: u4 @: ]"_

Cheers, bob

You say he is right:

"Yes, and the @:]"_ is redundant for any and all verbs u1 u2 u3 and u4.
And ([: u1 [:u2 u3@:u4) is another example equivalent..."

I think I proved you both wrong with this:

There is a considerable difference in memory allocation indicating
differences between these expressions. If the first version creates
three copies, the second seems to create five.


ts'([: - [: - [: - [: - ])i. 100000000'

1.45991 3.22123e9

ts'(- @: - @: - @: - )i. 100000000'

1.48942 5.36871e9

And this:

Its is some redundant calls to the @: conjunction that makes the
difference?

ts'(- @: - @: - @: - )i. 100000000'

1.56681 5.36871e9

c=: 2 :(':';'[: u v')

ts'(- c - c - c - )i. 100000000'

1.56479 5.36871e9

It is unclear which tacit J expression you mean by u1(u2(u3(u4(y)))).

/Erling



On 2016-08-05 22:22, Raul Miller wrote:

If you want the algorithm of u1(u2(u3(u4(y)))) and not any expression
with the same result, then you should be using u1(u2(u3(u4(y)))) and
not some other expression.

That said, you might want to wrap it in verb def '' (with the
expression going inside the quotes) so that you can have a verb
definition.

Thanks,


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