pcsoln.ax.txt - source file of 4 non-utility phonecode solution axioms - Table 1 of "Phonecode in Axiomatic Language" paper - see pcsolnX.ax.txt for version of this file with expanded comments ----+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----8 ! phonecode - encode phone numbers with words from a dictionary !/ A letter>digit map is applied to a dictionary file of words, one-per-line, to produce a matching of digit strings to words. Each word has >0 upper/lowercase letters. Phone numbers from a text file, one-per-line, are encoded as a string of words whose digit strings combine to form the number, with single phone number digits inserted where there is no matching word starting with that digit (but no consecutive digits allowed). Phone number-code pairs are written to an output file, one-per-line: phnum: d|[d ]word{[ d] word}[ d] - code words/digits (& blanks) Words and phone numbers can have special characters, which are ignored in the encoding but included in the output. A phone number may have >=0 codes. !\ 1 (Prog: ^(e jnq rwx dsy ft am civ bku lop ghz) digs>wd ph#enc pcfmt). ! 0 1 2 3 4 5 6 7 8 9 - digit for each uc/lc letter ! -> (Program _dic _ph#s _outf) - generated Program valid exprs ! Supporting functions and stack states (arguments numbered 0..): !stk: _dic _ph#s - initial stack w input text files ! ^(e jnq ... ghz) - "constant fn" pushes ltr>dig map expr onto stack !stk: (e jnq ... ghz) _dic _ph#s 2 (: digs>wd *sel1 x>d ltr> *&>{^ *rev). ! get digits>word map !stk: _digs>wd _ph#s - digs>wd map is seq of (digstr word) pairs 3 (: ph#enc dup1 (1 1*dig?{ *eat1^ *~cnsc?dig?{) *join). ! get codes !stk: (.. (_ph# _ph#codes) ..) - each phnum and its seq of codes 4 (: pcfmt *./join cat* (*ins1 ": ") (*:2ins_ ' ') *chxcat). !format p-c pairs !stk: _outf - output text file w formated ph#-code pairs