Talk:Text processing/Max licenses in use: Difference between revisions

(removed "file exists" assumption)
Line 6:
The J solution makes assumptions to allow the interesting code to stand out (rather than the drudgery). This obviously comes at the cost of some robustness (and, incidentally, optimizes for speed).
 
* Assumes the format of the file is fixed (therethat willchar always8 beof spaceseach inline columnsis <tt>7'I' 11or 13'O' 33as 37the 41</tt>).license is Thischecked canin beor changedout, easily to find columns of all spacesrespectively, and cut there; doing so would actually makethat the programdate shorteris andchars simpler,14-32 butof obviouslyeach slowerline).
 
* Does *'''not*''' assume the file exists or, if it exists, that it contains any data (i.e. it may be zero bytes long). For example, if the file is empty, you get this:
* Assumes columns 3 and 6 are Date and Job ID respectively. Could easily be checked; pattern matching would permit the code to identify the columns heuristically.
 
* Assumes a license will be checked out before it's checked in, and checked in before it's checked out, and that initially all licenses are checked in.
 
* Does *not* assume the file exists or, if it exists, that it contains any data (i.e. it may be zero bytes long). For example, if the file is empty, you get this:
Maximum simultaneous license use is 0 at the following times:
:Note that I didn't have to do any special checks to get this behavior, it just fell naturally out of the code. (This happens a lot in J.)
Anonymous user