Bo, I am so sorry for slagging off your program!
Had I known it was yours, I wouldn't have written what I did. I assumed this was an educational curio you came across (as I often used to do in hobby magazines) and hadn't quite known how it worked -- because you had claimed you didn't know how to turn it into J. I don't either. But I cheated, and sidestepped the problem. I doubt if I'd have been able to write it better, for its purpose. Which I'd say is to exhibit in lectures and not to support some commercial (or religious :-) enterprise. I've written reams of BASIC in my time, on all sorts of now-defunct machines, especially for IT courseware. I've taught Software Engineering at postgrad level -- so I think I'd be permitted to say that classic BASIC is not a language for dogmatically sound programming! Nevertheless my little "slur" served to make the point that to re-cast the algorithm to lend itself to J better, you actually find yourself untangling the PRINTs from the string-processing, i.e. separating processing from I/O (and preparation for I/O). I've migrated a lot of heritage code too, from mainframe to MSDOS to Windows to web -- and the more closely the programmer has stuck to the principle of separating processing from I/O the easier it is to migrate. It can't just be an accident. So I was grinding an axe there. I was doubtful about permitting (pray) to accept its y-arg as an integer as well as a string of digits. I only permitted it for the convenience of experimenters. Thus (pray '010') is decidedly not the same as (pray '10') but (pray 010) confounds the two. Thanks for explaining where the record numbering system came from. Since it didn't matter for the purpose of translating the code, I didn't make the effort to understand how it worked. But it's really a topic of investigation in its own right. It reminds me of Wittgenstein's paragraph-numbering system in Tractatus. I'd be grateful for a reference to "ordinal fractions" -- Wikipedia doesn't seem to recognise the term in an arithmetical rather than a linguistic sense. I guessed that it was a way of representing a tree as a single integer. Such a domain would have interesting mathematical properties, and a J library to handle it would have its uses, given the lack of an agreed "natural" way of handling trees in J, as opposed to Python say. (I'm forgetting of course the nested box structure delivered by 5!:1). IanClark On Thu, Nov 29, 2012 at 10:52 AM, Bo Jacoby <bojac...@yahoo.dk> wrote: > Ian, you did an amazing job! Thank you very much! > > You write about my BASIC program: "Like many amateur programs, it thoroughly > mixes up input, processing and output. Even in the 1960s when BASIC was > invented (Kemeny & Kurtz, > 1964) this was recognised to be a bad thing". Yes, everybody knew how to > criticize, but few BASIC programs were actually easy to read and understand. > My excuse, apart from being such an amateur, is that I kept it down to 8 > lines. It could have been worse. The input statements were INPUT;C$ which > reads a textstring from the terminal, and LINE INPUT#1,A$ which reads a > line from the file into a textstring. The output statements were PRINT":"; > which outputs a colon without carriage return, and PRINT which outputs > the carriage return - in those days the typewriter terminal had a physical > carriage to return - and PRINT" ";A$; which outputs first a blank > sign, then the word, and no carriage return. The statements A%=ASC(A$)-48: > A$=MID$(A$,2) translates the first digit in the line number into an > integer, and chops if off the string. > > The database structure is flexible in that it fuses the array structure and > the tree structure together into a single structure. Compare pray 0 with pray > 00 and pray 000 to see the tree structure, while pray 13500 shows a 2*2 array. > > > In extended versions of the program in FORTRAN and in Pascal I included an > editor to insert, modify and delete records. (If a record was there already > it was modified, otherwise it was inserted. Empty records were deleted.) > Modifying a line number restructured the database. For example changing 0 to > 2 ment that all line numbers in the database were prefixed by digit 2. > > > The line numbers are ordinal fractions: "1" is the first half and "2" is the > second half, "first" and "second" are ordinals and "half" is a fraction. > That's why! "0" means both halfs. > > > Ordinal fractions are like arrays except: > > * an array has only a finite number of dimension, while an > ordinalfraction has an infinite number of dimensions. > * arrays have different shapes, while all ordinalfractions have the > same shape. > * an array may have subarrays and elements, while an ordinalfraction > has sub - ordinalfractions, but no elements. > * arrayelements have values and subarrays do not have values, while > ordinalfractions have values. > I am fascinated by the power of ordinal fraction arithmetic, but it is far > more heretical than artificial catholicism. Beware of the inquisition! > > - Bo > > > >>________________________________ >> Fra: Ian Clark <earthspo...@gmail.com> >>Til: programm...@jsoftware.com >>Sendt: 3:58 torsdag den 29. november 2012 >>Emne: Re: [Jprogramming] Translating BASIC into J >> >>Here's my take on the topic: http://www.jsoftware.com/jwiki/IanClark/credo >> >>There's a script at the bottom of the wiki page you can download. >> >>I haven't attempted to replicate BASIC's itty-bitty I/O, all mixed-up >>in the processing. As well write a mini interpreter in J and get it to >>run the BASIC code! >> >>Instead I've intuited the algorithm and done it as a J-er would. >>Might. >>Would. >>(At least, as this J-er would). >> >>IanClark >> >>On Tue, Nov 27, 2012 at 6:31 AM, Bo Jacoby <bojac...@yahoo.dk> wrote: >>> Dear J'ers. >>> >>> At the Norddata conference in Göteborg in the summer 1989 I gave a lecture >>> (in Danish) on Ultraflexible Database Structure and Artificial Catholicism. >>> >>> >>> It contained this 8-liner in BASIC. >>> ...snipped... >>---------------------------------------------------------------------- >>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