home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol166 / asam.cnv < prev    next >
Encoding:
Text File  |  1984-04-29  |  2.4 KB  |  101 lines

  1.  
  2. [ASAM.CNV]
  3. [some sample programs for CNVRT]
  4. [28 March 1982]
  5.  
  6. [[
  7. A demonstration of CNVRT programs. The choices are
  8.         bsum - sum two strings of binary digits
  9.         merge - combine two lists into one
  10.         reverse - reverse a list
  11.         split - split a list into alternate elements
  12.         list - recognize typical list elements
  13.         word - some fancy word forms
  14.         quit - end the demonstration
  15.         ? - list the choices
  16. ]]
  17.  
  18.  
  19.  
  20. [binary sum]
  21. (()()(0 1 2)(
  22.     ((PWS,b )(or),);
  23.     (+=0<2>,+=<2>):
  24.     (+=<2>,<2>);
  25.     (<0>+=<2>,<0>+0=<2>):
  26.     (+<1>=<2>,0+<1>=<2>):
  27.     (<0>+*<2>,<0>+1<2>):
  28.     (<0>+<1>0*<2>,<0>+<1>1<2>):
  29.     (<0>+<1>1*<2>,<0>+<1>*0<2>):
  30.     (<0>0+<1>0=<2>,<0>+<1>=0<2>):
  31.     (<0>0+<1>1=<2>,<0>+<1>=1<2>):
  32.     (<0>1+<1>0=<2>,<0>+<1>=1<2>):
  33.     (<0>1+<1>1=<2>,<0>+<1>*=0<2>):
  34.   )) b
  35.  
  36. [merge two strings into a single string]
  37. (()()(0 1 2 3 4)(
  38.     ([<0> <1>][<2> <3>][<4>],[<1>][<3>][<4> <0> <2>]):
  39.     ([<0> <1>][<2>][<4>],<4> <0> <2> <1>);
  40.     ([<0>][<2>][<4>],<4> <0> <2>);
  41.   )) m
  42.  
  43. [reverse a list]
  44. (()()(0 1 2)(
  45.     ([<0> <1>][<2>],[<1>][<0> <2>]):
  46.     ([<0>][<2>],<0> <2>);
  47.   )) r
  48.  
  49. [split a string into evens and odds]
  50. (()()(0 1 2 3 4)(
  51.     ([<0> <1> <2>][<3>][<4>],[<2>][<0> <3>][<1> <4>]):
  52.     ([<0> <1>][<3>][<4>],<0> <3>(%|)<1> <4>);
  53.     ([][<3>][<4>],<3>(%|)<4>);
  54.     ([<0>][<3>][<4>],<0> <3>(%|)<4>);
  55.   )) s
  56.  
  57. [word types]
  58. ( (
  59. )()(1 2) (
  60.   (<1><1><1><>,tripled word :<1>:(%|)(w,<1>));
  61.   (<1><1><>,doubled word :<1>:(%|)(w,<1>));
  62.   ((and,<[1]>,<1>)<2><1><>,sandwich :<1>:^:<2>:^:<1>:(%|)(w,<2>));
  63.   (<-->1<-->2<-->3<-->4<-->5<-->,five in order);
  64.   (<-->(and,<[3]>,<1>)<--><1><--><1><-->,triple triple :<1>:);
  65.   (<-->(and,<[3]>,<1>)<--><1><-->,repeated triple :<1>:);
  66.   (<-->(and,<[2]>,<1>)<--><1><-->,repeated pair   :<1>:);
  67.   (<-->(and,<[1]>,<1>)<--><1><-->,repeated letter :<1>:);
  68.   (<1>,nothing word: <1>);
  69.    )) w
  70.  
  71. [list types]
  72. ( (
  73.   [letter]    ((AND,<[1]>,(NOT,(OR, ,<(>,<)>)))) a
  74.   [atom]    ((OR,<:a:><:b:>,<:a:>)) b
  75.   [goodparen]    ((OR, ,<:b:>,<:e:>)) c
  76.   [goodseq]    ((OR,<:c:><:d:>,)) d
  77.   [list]    (<(><:d:><)>) e
  78.    )
  79. ()() (
  80.   (<:a:><>,letter);
  81.   (<:b:><>,atom);
  82.   (<:e:><>,list);
  83.   (<:d:><>,good sequence);
  84.   (,not typical);
  85.    )) x
  86.  
  87. ( ()()() (
  88.    (word,(%C,(w,(%R)))(%R)):
  89.    (list,(%C,(x,(%R)))(%R)):
  90.    (bsum,(%C,(b,(%R)+(%R)=))(%R)):
  91.    (merge,(%C,(m,[(%R)][(%R)][]))(%R)):
  92.    (quit,);
  93.    (reverse,(%C,(r,[(%R)][]))(%R)):
  94.    (split,(%C,(s,[(%R)][][]))(%R)):
  95.    (??,(%D)(%R)):
  96.    (?,(%C, bsum merge reverse split word list quit)(%R)):
  97.    (,(%C,quit to exit, ? for menu)(%R)):
  98.    ))
  99.  
  100. [end]
  101.