When I tried your example I got a result for the variable  x  when it was
not defined.  That's a neat trick! You probably timed a variable that
differed from the "fox" sentence as our results are quite different. Also,
my results are also not as close as you indicated.

   state=: 3 2 2$ 1 1 2 1  2 0 2 2 1 0 2 2
   S=:0;state;<a.={.a
   (S&;: -: <;.1) k=:' the quick brown fox jumps over the lazy dog'
1
   timer=: 6!:2
   
   10 timer '<;.1 x'
5.85968e_6
   10 timer 'S&;: x'
7.87111e_6
   x
|value error: x
   
   timer '<;.1 '' the quick brown fox jumps over the lazy dog'''
1.61333e_5
   timer 'S&;: '' the quick brown fox jumps over the lazy dog'''
2.57016e_5

-----Original Message-----
From: programming-boun...@jsoftware.com
[mailto:programming-boun...@jsoftware.com] On Behalf Of Roger Hui
Sent: Thursday, March 08, 2012 10:05 PM
To: Programming forum
Subject: Re: [Jprogramming] Sequential Machine

Yes it is.  The example looks strange because the first character of a is
"a", not normally used as a separator.  If the first character is a blank
(say), then it looks more normal.  e.g.

   state=: 3 2 2$ 1 1 2 1  2 0 2 2 1 0  2 2
   a=: ' a good way to start the day'
   (0;state;<a.={.a);:a;:a
---T-----T----T---T------T----T----┐
│ a│ good│ way│ to│ start│ the│ day│
L--+-----+----+---+------+----+-----
   <;.1 a
---T-----T----T---T------T----T----┐
│ a│ good│ way│ to│ start│ the│ day│
L--+-----+----+---+------+----+-----
   S=: 0;state;<a.={.a
   (S&;: -: <;.1) a
1
   (S&;: -: <;.1) ' the quick brown fox jumps over the lazy dog'
1
   x=: 1e6$' the quick brown fox jumps over the lazy dog'
   (S&;: -: <;.1) x
1

Now the thing that surprised me when I saw it the first time:

   timer=: 6!:2
   10 timer '<;.1 x'
0.0630174
   10 timer 'S&;: x'
0.0675069

<;.1 is implemented using hand-coded C.



2012/3/8 Linda Alvord <lindaalv...@verizon.net>

> Roger, I'm not sure that this is  what you had in mind.
>
>
>   a=:'a good way to start the day'
>   <;.1 a
> ---------T--------T---------T--┐
> │a good w│ay to st│art the d│ay│
> L--------+--------+---------+---
>   state=: 3 2 2$ 1 1 2 1  2 0 2 2 1 0  2 2
>   (0;state;<a.={.a);:a
> ---------T--------T---------T--┐
> │a good w│ay to st│art the d│ay│
> L--------+--------+---------+---
>
>
----------------------------------------------------------------------
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