Newsgroups: comp.lang.apl
Path: watmath!watserv1!utgpu!news-server.csri.toronto.edu!torsqnt!tmsoft!itcyyz!yrloc!hui
From: hui@yrloc.ipsa.reuter.COM (Roger Hui)
Subject: Re: I'm *so* confused....
Message-ID: <1992Feb20.054011.20829@yrloc.ipsa.reuter.COM>
Keywords: J 4.1
Organization: Iverson Software Inc.
References: <9200131@s4mjs.UUCP> <9200133@s4mjs.UUCP>
Date: Thu, 20 Feb 92 05:40:11 GMT

Re the problem posed by M.J. Shannon Jr.
 
In solving a problem, an approach that I find useful is to define 
functions for meaningful components.  Well-chosen sub-functions provide 
a vocabulary for discourse and illustrate the structure of the solution 
in a way that no amount of comments can.  The approach is independent of 
the programming language.  (End of sermon :-)
 
An alternative solution to the problem:
 
read   =. 1!:1
nul    =. 0{a.
strcpy =. +./\.@(~:&nul) # ]
dir    =. ,&16@(%&16)@# $ ]
inode  =. 256&#. @ (a.&i.) @ (1 0&{) " 1
name   =. < @ strcpy @ (2&}.) " 1
Dir    =. (inode ;"0  name) @ dir @ read
 
<read> reads a file.  <nul> is the ASCII null character.  <strcpy> removes
trailing null characters from a string.
 
<dir> applies to a string of catenated directory entries, 16-bytes each,
and returns a 16-column table of the entries.  <inode> applies to an array
of directory entries and produces the "inode" numbers.  <name> applies
to an array of directory entries and produces the names, individually boxed.
<Dir> applies to the name of a file containing directory entries and
produces a 2-column table of inode numbers and names, individually boxed.

------------------------------------
Roger Hui, Iverson Software Inc., 33 Major Street, Toronto, Ontario  M5S 2K9
Phone: (416) 925 6096;  Fax: (416) 488 7559
