Your explanations helped a lot. One last puzzle. How can there be a result
when there is no x ? I start up and do this first in jijx . Is it timing
a syntax error of some sort?
J Http Server
timer=: 6!:2
10 timer '<;.1 x'
5.73397e_6
5.99238e_6
5.99238e_6
x
|value error: x
Linda
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Roger Hui
Sent: Friday, March 09, 2012 1:35 AM
To: Programming forum
Subject: Re: [Jprogramming] Sequential Machine
x was defined in my msg; it was:
x=: 1e6$' the quick brown fox jumps over the lazy dog'
new
It is hard to draw any conclusions on arguments as small as those used in
your msg. However, anything in J coming within a factor of 2 of handcoded
C, as in the timings in your example, is an accomplishment.
2012/3/8 Linda Alvord <[email protected]>
> 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: [email protected]
> [mailto:[email protected]] 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 <[email protected]>
>
> > 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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm