For the example given, there isn't much difference:

   ts '}.@:({.@>) a'
9e_6 1344
   ts '}. {. "1 > a'
8e_6 1408

But for a bigger example the @/@: version is faster and uses less space:

   b =: <@i."0 i.1000
   8{.b
++-+---+-----+-------+---------+-----------+-------------+
||0|0 1|0 1 2|0 1 2 3|0 1 2 3 4|0 1 2 3 4 5|0 1 2 3 4 5 6|
++-+---+-----+-------+---------+-----------+-------------+
   ts '}.@:({.@>) b'
0.000528 9408
   ts '}. {. "1 > b'
0.004844 4203648

Also, a number of expressions with @ or @: are recognised and special
code is used (see http://www.jsoftware.com/help/dictionary/special.htm),
usually with time and space savings and/or other benefits.

0j1

[EMAIL PROTECTED] wrote:
----------------------------------------------------------------------

Message: 1
Date: Thu, 11 Sep 2008 16:10:28 +0800
From: "Alex Rufon" <[EMAIL PROTECTED]>
Subject: [Jgeneral] Verb Sequences - u@:v and [EMAIL PROTECTED]
To: "General forum" <[email protected]>
Message-ID:
        <[EMAIL PROTECTED]>
Content-Type: text/plain;       charset="us-ascii"

Hi.

I'm at Chapter 12 of J for C Programmers and Henry was explaining verb
sequences.

You see, I have never ever used @: or @ in my years of use of J so this
is a bit confusing for me.

Like in the example on page 111 where it defines:
   ]a=: 1 2 3; 4 5; 6 7 8
+-----+---+-----+
|1 2 3|4 5|6 7 8|
+-----+---+-----+

The requirement was remove the first box and just get the first items of
the succeeding boxes. The solution that was provided was:
   }.@:({.@>) a
4 6

Since I've don't use "Verb Sequences", my solution was:
   }. {. "1 > a
4 6

I tried doing the other samples and I can still come up with solutions
without using the @ and @: symbols.

So I am wondering if anybody has good examples where I would absolutely
need to use verb sequencing so I can compromise with myself when to
properly use the symbols.

Thanks.

r/alex


------------------------------



----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to