I've been trying out Chris Collins code and I believe there may be a bug. So
here is my J session.
NB. =
NB. Start of J session
load 'data/jdb'
[ffd=: Open_jdb_ jpath '~temp'
+-+
|1|
+-+
Drop__ffd 'testdb'
[db=: Create__ffd
Working on it some more, I am more convinced that this is a bug. Since, you
would not be able to simulate this problem if you have more than one column
like so:
ht=: Create__db 'tblTest';0 : 0
Field1 int
Field2 varchar
)
Insert__db 'tblTest';0;'a'
Reads__db 'from tblTest'
Here is a recursive tacit solution, again sans parsing.
x=. @[
y=. @]
pat=. 0{::x
sub=. 1{::x
term=.2{::x
string=. 0{::y
trash=. 1{::y
EMPTY=. 0 3$a:
empty=. EMPTY_
patin=. {.x (pat (1:e.E.) ]) string
firstmatch=. [:{.[:I. pat E.]
rplcfirst=. (]}.~firstmatc...@pat) ,~ sub ,~ firstmatch {. ]
Beware of the line wrap on the definition of 'markov'.
On Thu, Dec 17, 2009 at 10:39 AM, Thomas Costigliola tcost...@gmail.com wrote:
Here is a recursive tacit solution, again sans parsing.
x=. @[
y=. @]
pat=. 0{::x
sub=. 1{::x
term=.2{::x
string=. 0{::y
trash=. 1{::y
EMPTY=. 0 3$a:
Dan Bron wrote:
Extended ints, like boxes, are reference types*. Amending an array of
reference types takes time proportional to the size of the
entire array; this is in contrast to amending an array of value types, which
takes time proportional to the size of the index array
(i.e. the
FYI, this a direct translation of a solution I did initially in ocaml.
I never actually ran the ocaml code because I didn't want to write the
string replacement and search functions or use the regexp library. The
interesting thing is that I had no desire to run it; I was pretty
confident it was
Do you agree on this?
S - .shop
A - apple
B - bag
T - the
the shop - my brother
a never used - .terminating rule
Sample text of:
I bought in S a B of As from T S.
Should generate:
I bought in shop a bag of apples from T S.
And how about this?
S - .shop
A - apple S
B - bag
T - the
the
R.E. Boss wrote:
Do you agree on this?
S - .shop
A - apple
B - bag
T - the
the shop - my brother
a never used - .terminating rule
Sample text of:
I bought in S a B of As from T S.
Should generate:
I bought in shop a bag of apples from T S.
I think the result should
I disagree with both unless my understanding is wrong. The first rule
'S' is terminating in both cases and in both cases an 'S' is in the
input so the algorithm should stop after the first replacement. Also
in the second case I suspect a typo in the input string based on your
output string...
Oops, typo in the first case:
Viktor Cerovski wrote:
R.E. Boss wrote:
Do you agree on this?
S - .shop
A - apple
B - bag
T - the
the shop - my brother
a never used - .terminating rule
Sample text of:
I bought in S a B of As from T S.
Should generate:
I bought in
I was not careful enough, but still do not agree. See below.
Viktor Cerovski wrote
R.E. Boss wrote:
Do you agree on this?
S - .shop
A - apple
B - bag
T - the
the shop - my brother
a never used - .terminating rule
Sample text of:
I bought in S a B of As from T S.
Viktor Cerovski viktor.cerovski at gmail.com
Thu Dec 17 09:45:52 HKT 2009
Slightly shorter/faster/neater:
mapply1=: 4 : 0
t=.ri=.0
while. (-.t) *. ri#x do.
'p s t'=.ri{x
y=.(s , (#p) }. ]).((z i. 1)|.)^:(f=.+./z=.p E. y) y
ri=.(-.f)*ri+1
end.
y
)
As far as I understand,
On Thu, Dec 17, 2009 at 1:14 PM, R.E. Boss r.e.b...@planet.nl wrote:
I was not careful enough, but still do not agree. See below.
Viktor Cerovski wrote
R.E. Boss wrote:
Do you agree on this?
S - .shop
A - apple
B - bag
T - the
the shop - my brother
a never used -
R.E. Boss wrote:
I was not careful enough, but still do not agree. See below. [italics
added]
I agree---If you read my post carefully, you would have seen
below the text you quoted also the following text:
In both cases the first rule is applied and
the rewriting terminated.
--
Thomas Costigliola wrote:
Recursive solutions, when written clearly, are easy to reason about and
often seem obviously correct.
I think this is a fair statement, qualified with depending on the notion they
express. I do not think all loops would be easier
to understand as recursive calls.
Andrew Nikitin wrote:
Viktor Cerovski viktor.cerovski at gmail.com
Thu Dec 17 09:45:52 HKT 2009
Slightly shorter/faster/neater:
mapply1=: 4 : 0
t=.ri=.0
while. (-.t) *. ri#x do.
'p s t'=.ri{x
y=.(s , (#p) }. ]).((z i. 1)|.)^:(f=.+./z=.p E. y) y
ri=.(-.f)*ri+1
end.
y
)
On Thu, Dec 17, 2009 at 2:03 PM, Dan Bron j...@bron.us wrote:
Thomas Costigliola wrote:
Recursive solutions, when written clearly, are easy to reason about and
often seem obviously correct.
I think this is a fair statement, qualified with depending on the notion
they express. I do not
On Sat, Dec 12, 2009 at 9:26 AM, Dan Bron j...@bron.us wrote:
Raul wrote:
If you want to go for largest roundest base, then this might
be worth pursuing?
Yes, let's try that.
I can not see any better solution here
than trying all possible factors.
--
Raul
Thomas Costigliola-2 wrote:
FYI, this a direct translation of a solution I did initially in ocaml.
I never actually ran the ocaml code because I didn't want to write the
string replacement and search functions or use the regexp library. The
interesting thing is that I had no desire to run
On Thu, Dec 17, 2009 at 2:03 PM, Dan Bron j...@bron.us wrote:
I wish the interpreter optimized tail calls, and my
intuition is that it would be easy to identify optimizable
verbs algebraically. At least the tacit ones.
It seems to me that ^: already lets us deal adequately
with the easily
If the rules are
AbA - A
AbA - B
what becomes AbAbA then? A or B?
R.E. Boss
--
For information about J forums see http://www.jsoftware.com/forums.htm
I wrote:
I wish the interpreter optimized tail calls, and my
intuition is that it would be easy to identify optimizable
verbs algebraically. At least the tacit ones.
Raul responded:
It seems to me that ^: already lets us deal adequately
with the easily optimizable cases?
I made a similar
R.E. wrote:
If the rules are
AbA - A
AbA - B
what becomes AbAbA then? A or B?
Because evaluation starts all over after every successful match, the answer
is A. Tracing the evaluation:
Start
Input : AbAbA
Apply rule 0 : AbA - A
Match leftmost pattern: AbAbA
Sherlock, Ric r.g.sherl...@massey.ac.nz writes:
Might be worthwhile looking up the C source for .import and working
out what SQL it is creating.
Thanks, Ric. I looked today, but the import didn't seem to have any SQL
there. I think I'll look at apply and bulkins tomorrow.
Bill
--
Bill
ĵaŭ, 17 Dec 2009, christopher collins skribis:
NB. The insert below causes a failure
NB. After this the table can no longer be read.
NB. QUESTION: Is that behavior intended?
NB. If so, JDB seems a little fragile for the rough, unskilled hands
of newbies like me
NB. This insert, where '01' is
Thank you, Mr. Lam and Mr. Rufon and all others for your assistance
and instruction.
--chris--
--
For information about J forums see http://www.jsoftware.com/forums.htm
Errr ... thanks but Mr. Rufon is my Dad. :P
You should call me Alex.
Slow day today ... stuck in a meeting ...
-Original Message-
From: programming-boun...@jsoftware.com
[mailto:programming-boun...@jsoftware.com] On Behalf Of christopher collins
Sent: Friday, December 18, 2009 1:30
27 matches
Mail list logo