[Jprogramming] JDB Error Handling Bug? (WAS: RE: Newbie JDB problem: inserting chars in a 1 column char table gives 'assertion failure')

2009-12-17 Thread Alex Rufon
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

Re: [Jprogramming] JDB Error Handling Bug? (WAS: RE: Newbie JDB problem: inserting chars in a 1 column char table gives 'assertion failure')

2009-12-17 Thread Alex Rufon
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'

Re: [Jprogramming] Tacit exercise

2009-12-17 Thread Thomas Costigliola
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 {. ]

Re: [Jprogramming] Tacit exercise

2009-12-17 Thread Thomas Costigliola
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:

Re: [Jprogramming] Amending big array

2009-12-17 Thread miridian
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

Re: [Jprogramming] Tacit exercise

2009-12-17 Thread Thomas Costigliola
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

Re: [Jprogramming] Tacit exercise

2009-12-17 Thread R.E. Boss
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

Re: [Jprogramming] Tacit exercise

2009-12-17 Thread Viktor Cerovski
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

Re: [Jprogramming] Tacit exercise

2009-12-17 Thread Thomas Costigliola
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...

Re: [Jprogramming] Tacit exercise

2009-12-17 Thread Viktor Cerovski
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

Re: [Jprogramming] Tacit exercise

2009-12-17 Thread R.E. Boss
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.

[Jprogramming] Tacit exercise

2009-12-17 Thread Andrew Nikitin
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,

Re: [Jprogramming] Tacit exercise

2009-12-17 Thread Thomas Costigliola
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 -

Re: [Jprogramming] Tacit exercise

2009-12-17 Thread Viktor Cerovski
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. --

Re: [Jprogramming] Tacit exercise

2009-12-17 Thread Dan Bron
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.

Re: [Jprogramming] Tacit exercise

2009-12-17 Thread Viktor Cerovski
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 )

Re: [Jprogramming] Tacit exercise

2009-12-17 Thread Thomas Costigliola
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

Re: [Jprogramming] Round numbers

2009-12-17 Thread Raul Miller
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

Re: [Jprogramming] Tacit exercise

2009-12-17 Thread Viktor Cerovski
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

Re: [Jprogramming] Tacit exercise

2009-12-17 Thread Raul Miller
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

Re: [Jprogramming] Tacit exercise

2009-12-17 Thread R.E. Boss
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

Re: [Jprogramming] Tacit exercise

2009-12-17 Thread Dan Bron
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

Re: [Jprogramming] Tacit exercise

2009-12-17 Thread Dan Bron
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

Re: [Jprogramming] SQLite dot commands

2009-12-17 Thread Bill Harris
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

Re: [Jprogramming] Newbie JDB problem: inserting chars in a 1 column char table gives 'assertion failure'

2009-12-17 Thread bill lam
ĵ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

[Jprogramming] Newbie JDB problem: inserting chars in a 1 column char table gives 'assertion failure'

2009-12-17 Thread christopher collins
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

Re: [Jprogramming] Newbie JDB problem: inserting chars in a 1 column char table gives 'assertion failure'

2009-12-17 Thread Alex Rufon
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