There appears to be a locale-related bug in trace in handling names:
cocurrent <'base'
a=:1 2 3 4 5 6 7
trace 'a ( < # [) 4'
--------------- 5 Trident ----
<
#
[
< # [
--------------- 8 Paren ------
(
< # [
)
< # [
--------------- 1 Monad ------
< # [
4
|domain error: executet
| t_z=. (<#[)(4)
cocurrent <'jtrace'
a
|value error: a
a=:1 2 3 4 5 6 7
trace 'a ( < # [) 4'
--------------- 5 Trident ----
<
#
[
< # [
--------------- 8 Paren ------
(
< # [
)
< # [
--------------- 2 Dyad -------
1 2 3 4 5 6 7
< # [
4
1 2 3
==============================
1 2 3
'a' has no value in the locale 'jtrace' and is being identified as a verb.
--
David Mitchell
Yuvaraj Athur Raghuvir wrote:
> Hello,
>
> I wanted to check on the trace verb and I got stuck with this:
>
> a =: 1 2 3 4 5 6 7
> a
> 1 2 3 4 5 6 7
> a ( < # [) 4
> 1 2 3
> trace 'a ( < # [) 4'
> --------------- 5 Trident ----
> <
> #
> [
> < # [
> --------------- 8 Paren ------
> (
> < # [
> )
> < # [
> --------------- 1 Monad ------
> < # [
> 4
> |domain error: executet
> | t_z=. (<#[)(4)
>
> What am I missing?
>
> Regards,
> Yuva
>
> On Thu, Jul 30, 2009 at 10:45 AM, Zsbán Ambrus <[email protected]> wrote:
>
>> On Wed, Jul 29, 2009 at 8:57 AM, Roger
>> Stokes<[email protected]> wrote:
>>> NB. trace can produce an incorrect result.
>>>
>>> require 'trace'
>>>
>>> a =: 6
>>> trace '(a=:7) , a'
>> ...
>>> 7 7
>>>
>>> NB. the correct result is shown by:
>>>
>>> a =: 6
>>> (a=:7) , a
>>> 7 6
>> Wow, I had to look up in the dictionary whether this behaivior is
>> supported. The chapter "Parsing and Execution" says
>>
>>> Parsing proceeds by moving successive elements (or their values except in
>> the case of proverbs and names immediately to the left of a copula) from the
>> tail end of a queue (initially the original sentence prefixed by a marker §)
>> to the top of a stack (initially four markers), and eventually executing
>> some eligible portion of the stack and replacing it by the result of the
>> execution.
>>
>> and later it says
>>
>>> The executions in the stack are confined to the first four elements only,
>> and eligibility for execution is determined only by the class of each
>> element (noun, verb, etc., an unassigned name being treated as a verb), as
>> prescribed in the following parse table. The classes of the first four
>> elements of the stack are compared with the first four columns of the table,
>> and the first row that agrees in all four columns is selected. The bold
>> italic elements in the row are then subjected to the action shown in the
>> final column, and are replaced by its result. If no row is satisfied, the
>> next element is transferred from the queue.
>>
>> which defines exactly when a name is converted to its value or a
>> proverb (the latter for names whose value is verb or undefined). For
>> some reason I thought the dictionary left when this happens during
>> execution partially undefined on purpose, but no.
>>
>> Ambrus
>> ----------------------------------------------------------------------
>> 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