CoSy.com
719-337-2733

  • CoSy
  • Glass Tables
  • CoSy/Life
  • CoSy/Liberty
  • Spire for WTC site
  • ?Wha?
  • cursor hover comments
  • Feedback
    © Bob Armstrong
    /(/ sun.jun.20060611.140512 /)/
  • /CoSy ­/CoSy ­/CoSy ­/UserManual
    Search CoSy
     
         by FreeFind
    Site Map What's New
    powered by FreeFind
    User Notes

    I've gotten enough code working now in Ron Aaron's Reva to present to FORTH programmers for use as a system of dynamic lists with much of the power of a 0th generation APL , and also to mark a point at which I could really use some insights from some of my high powered ( mentally ) friends who actually know how to write an APL .
    See CoSy/Language for an overview of the structure of the language and its objects . There is still a very long way to go , and there is no assurance that many of the words here will be stable - some will disappear as they are generalized - but many of the concepts will remain .

    While general recursive arrays and the requisite reference counting appear to be working , it's just operations on simple arrays I'll discuss now .

    The way I use Reva is to download the current version in to a \revaArk directory then unzip it into \ creating , or overwriting \reva . Make a directory \reva\CoSy and extract CoSy.zip into it .

    Then cd to \reva and execute bin\reva CoSy\CoSy.f . I keep a CoSy.bat file with this instruction in \reva as a shortcut .

    In the current file , the varible DEBUGGING is on which compiles tracking messages for allocation , freeing and reference counting of objects . It also has prompt vectored to stkprmpt to type .s in Hex on every execution . undo prompt will restore the standard prompt .

    Three types of primitive lists are currently supported : string , 32 bit integer and 80 bit float .

    First , here are the examples with all the debugging output eliminated .

      | Strings :
      
        ok> s" This is just an EXAMPLE , not very long string ."    | This is allocated space .
      
        ok> refs+> value aString		| Increment the reference count because something ,
                           		  	| aString , is referring to it so don't garbage collect ( free ) .
      
        ok> aString i# .        		| How many items , in this case bytes ?
      48
      
        ok> aString 6 i@ emit        	| Fetch item 6 ( 0 origin )
      s
      
        ok> 'I aString 5 i!        	| Store a capital "I" into item 5 .
      
        ok> aString ' emit eachM    	| Apply the non-resulting function emit to each item .
      This Is just an EXAMPLE , not very long string .
                                 		| The "M" stands for "Monadic" , APL for single argument
      
        ok> aString ' lc eachMbr    	| Apply the lower case function to each item returning
                                      | The result in a new list .
      
        ok> S.        | S. is equivalent to ' emit eachM . Output it as before .
      this is just a example , not very long string .
                  	| Note because the reference count was left at 0 the string is freed .
      
      
      | Integers :
      
        ok> i( 1 2 3 42 )i refs+> value aInt    | create and store an integer vector
      
        ok> aInt i( 10 100 1000 10000 )i ' + eachDcr    | add each corresponding item
                                      | note this is Dyadic ( 2 argument ) cellwise resulting
      
        ok> ' . eachM               	| output each .
      11 102 1003 10042
      
        ok> : I. ' . eachM ;
      
        ok> aInt i( 10 100 )i *i  I.      | All the basic functions , + - * / _mod , etc are
      				| provided as functions with a suffix i .
      				| The definition will be extended to apply pervasively to
      				| the leaves of deeper arrays .
      10 200 30 4200  | Note with modulo indexing the shorter list is
                  	| used cyclically to match the longer .
      
        ok> aInt i( 10 )i <i I.  	| Booleans are simply 1s and 0s .
      1 1 1 0
      
        ok> 10 iota I.		| One of APL's surprisingly useful functions is iota which
      0 1 2 3 4 5 6 7 8 9 	| returns the first n integers .
      
        ok> 10000 iota ' + acrossC .  	| acrossC applies a function "across" a cell list .
                  				| Thus ' * acrossC sums a list of integers .
        ok> 10000 iota i( 1 )i +i  ' + acrossC .    | Same , adding 1 to each integer .
      50005000
      
      | Floats :
      
        ok> 2 sigdig !
      
        ok> f( 1. 3.14 2.78e5 )f f( 10.0 )f ' f* eachDfr F.        | each Dyadic float resulting
      10.00 31.39 2779999.99
      
        ok> 2. fpi f* 100. f/ fconstant 2pi/100
      
        ok> 100 iota i>f refs+> value aFloat    	| convert integers to floats and store
      
        ok> mark || aFloat :: 2pi/100 f* fcos ; eachMfr ||
      	| Generate cosines on a hundred points on a circle .
      
        ok> F.
      1.00 0.99 0.99 0.98 0.96 0.95 0.92 0.90 0.87 0.84 0.80 0.77 0.72 0.68 0.63 0.58
      0.53 0.48 0.42 0.36 0.30 0.24 0.18 0.12 0.06 0.00 -0.06 -0.12 -0.18 -0.24 -0.30
      -0.36 -0.42 -0.48 -0.53 -0.58 -0.63 -0.68 -0.72 -0.77 -0.80 -0.84 -0.87 -0.90 -0
      .92 -0.95 -0.96 -0.98 -0.99 -0.99 -0.99 -0.99 -0.99 -0.98 -0.96 -0.95 -0.92 -0.9
      0 -0.87 -0.84 -0.80 -0.77 -0.72 -0.68 -0.63 -0.58 -0.53 -0.48 -0.42 -0.36 -0.30
      -0.24 -0.18 -0.12 -0.06 -0.00 0.06 0.12 0.18 0.24 0.30 0.36 0.42 0.48 0.53 0.58
      0.63 0.68 0.72 0.77 0.80 0.84 0.87 0.90 0.92 0.95 0.96 0.98 0.99 0.99
      
      
    Below are the same examples with the debugging output turned on .
       
    • Strings : ok> s" This is just an EXAMPLE , not very long string ." allocating 990A8 (1) 990A8 | Stack output in hex for debugging . ok> D> | Utility dump of 32 bytes , returning argument . 000990A8 F8 FF FF FF 30 00 00 00 00 00 08 00 54 68 69 73 ....0.......This 000990B8 20 69 73 20 6A 75 73 74 20 61 6E 20 45 58 41 4D is just an EXAM (1) 990A8 ok> refs+> value aString | Increment the reference count because something , r+ 990A8 (0) | aString , is referring to it . ok> aString i# . | How many items , in this case bytes ? 48 (0) ok> aString 6 i@ emit | Fetch item 6 ( 0 origin ) s(0) ok> 'I aString 5 i! | Store a capital "I" into item 5 . (0) ok> aString ' emit eachM | Apply the non-resulting function emit to each item . This Is just an EXAMPLE , not very long string .(0) | The "M" stands for "Monadic" , APL for single argument ok> aString ' lc eachMbr | Apply the lower case function to each item returning allocating 990F8 (1) 990F8 | The result in a new list . ok> S. | S. is equivalent to ' emit eachM . Output it as before . this is just a example , not very long string . freeing 990F8 (0) | Note because the reference count was left at 0 the string is freed . ok> aString DMP | D> is really just dup DMP . 000990A8 F8 FF FF FF 30 00 00 00 01 00 08 00 54 68 69 73 ....0.......This 000990B8 20 49 73 20 6A 75 73 74 20 61 6E 20 45 58 41 4D Is just an EXAM (0) | compare this with the original dump and you will | notice the reference count in the 3rd cell is 1 .
    • Integers :
      ok> i( 1 2 3 42 )i refs+> value aInt	| create and store an integer vector
       allocating 180048
       r+ 180048 (0)
      
      ok> aInt i( 10 100 1000 10000 )i ' + eachDcr	| add each corresponding item
       allocating 180078		| note this is Dyadic ( 2 argument ) cellwise resulting
       allocating 99108
       freeing 180078
      (1) 99108
      
      ok> ' . eachM			| output each .
      11 102 1003 10042  freeing 99108
      (0)
      
      ok> : I. ' . eachM ;
      (0)
      
      ok> aInt i( 10 100 )i *i  I.	| All the basic functions , + - * / _mod , etc are
       allocating 180078			| provided as functions with a suffix i .
       allocating 99108			| The definition will be extended to apply pervasively to
       freeing 180078				| the leaves of deeper arrays .
      10 200 30 4200  freeing 99108	| Note with modulo indexing the shorter list is
      			| used cyclically to match the longer .
      
      ok> aInt i( 10 )i  <i  I.	| Booleans are simply 1s and 0s .
       allocating 180078
       allocating 99078
       freeing 180078
      1 1 1 0  freeing 99078
      (0)
      
      ok> 10 iota I.			| One of APL's surprisingly useful functions is iota which
       allocating 180048		| returns the first n integers .
      0 1 2 3 4 5 6 7 8 9  freeing 180048
      (0)
      
      ok> 10000 iota ' + acrossC .	| acrossC applies a function "across" a cell list .
       allocating 180048			| Thus ' * acrossC sums a list of integers .
       freeing 180048
      49995000 (0)
      
      ok> 10000 iota i( 1 )i +i  ' + acrossC .	| Same , adding 1 to each integer .
       allocating 180048
       allocating 189CA8
       allocating 189CC8
       freeing 189CA8
       freeing 180048
       freeing 189CC8
      50005000 (0)
      
      
    • Floats :
      
      ok> 2 sigdig !
      (0)
      
      ok> f( 1. 3.14 2.78e5 )f f( 10.0 )f ' f* eachDfr F.		| each Dyadic float resulting
       allocating 180020
       allocating 280020
       allocating 99278
       freeing 280020
       freeing 180020
      10.00 31.39 2779999.99  freeing 99278
      (0)
      
      ok> 2. fpi f* 100. f/ fconstant 2pi/100
      (0)
      
      ok> 100 iota i>f refs+> value aFloat	| convert integers to floats and store
       allocating 99278
       allocating 99428
       freeing 99278
       r+ 99428 (0)
      
      ok> mark || aFloat :: 2pi/100 f* fcos ; eachMfr ||  Generate cosines on a hundred points on a circle .
       allocating 99828
      (1) 99828
      
      ok> F.
      1.00 0.99 0.99 0.98 0.96 0.95 0.92 0.90 0.87 0.84 0.80 0.77 0.72 0.68 0.63 0.58
      0.53 0.48 0.42 0.36 0.30 0.24 0.18 0.12 0.06 0.00 -0.06 -0.12 -0.18 -0.24 -0.30
      -0.36 -0.42 -0.48 -0.53 -0.58 -0.63 -0.68 -0.72 -0.77 -0.80 -0.84 -0.87 -0.90 -0
      .92 -0.95 -0.96 -0.98 -0.99 -0.99 -0.99 -0.99 -0.99 -0.98 -0.96 -0.95 -0.92 -0.9
      0 -0.87 -0.84 -0.80 -0.77 -0.72 -0.68 -0.63 -0.58 -0.53 -0.48 -0.42 -0.36 -0.30
      -0.24 -0.18 -0.12 -0.06 -0.00 0.06 0.12 0.18 0.24 0.30 0.36 0.42 0.48 0.53 0.58
      0.63 0.68 0.72 0.77 0.80 0.84 0.87 0.90 0.92 0.95 0.96 0.98 0.99 0.99  freeing 9
      9828
      (0)
      
      
    That's all I'm going to cover now . Comments desired .
       
    CoSy : Ultimate Executive NoteComputer
    Note : I reserve the right to post all communications I receive or generate to CoSy website for further reflection .
    Contact : Bob Armstrong ; About this page : Feedback ; 719-337-2733
    Coherent Systems / 28124 Highway 67 / Woodland Park , Colorado / 80863-9711
    /\ /\ Top /\ /\