Comment on
Dyalog APL
Forum
  • 4th.CoSy
  • Planetary Temperature
  • CoSy/Life ; CoSy/Liberty
  •  FaceBook ; Twitter 
         ; YouTube ;

  • © Bob Armstrong


    Re: tally and scalar functions

    Postby Bob Armstrong on Sun Apr 19, 2020 12:02 pm

    You may know CoSy evolved thru Arthur Whitney's K which follows Backus's Turing talk ( which I think set the stage for Ken's the next year ) observation a matrix was just a list of lists of equal length . So , the equivalent of ≢ , for which Arthur uses # , and I couldn't help my nostalgia from using ` rho , is the only fundamental count verb .

    CoSy in an open to the x86 Forth uses whitespace as the prime delimiter of words , which makes it possible to make far more expressive names than either K or J which are also ( self ) restricted to the ascii keyboard .
    The header of a CoSy list ( everything is a list ) is `( Type Count refCount )` . So the definition of ≢ , CoSy's ` i# is , at the naked x86 level , simply
    : ≢ cell+ @ ;
    where ` @ , Forth's ` fetch , is just
     8B 00   mov eax,[eax]
     C3      ret
    Forth's simple RPN and the ` ' verb which returns the address of the following word ( ` returns the word following as a string ) makes a lot of constructions much simpler than in traditional APLs .

    But , getting to the point , one of the decisions in CoSy I am most happy with is modulo indexing . There is no intrinsic notion of dimension , ie: rank , specifically 0 rank .
    For example , with modulo indexing :
       10 _i iota
    0 1 2 3 4 5 6 7 8 9
       R0 i( 1 -1 )i +i
    1 0 3 2 5 4 7 6 9 8
    So there is never such a thing as a ` Index error . All trees are conformable with all other trees . Effectively , rather than being lists of lists they are rings of rings . ( NB: that _i is necessary to convert the naked 10 on the x86 stack to a 1 item CoSy list . And you can see I've never ` genericized most operations like add . Good learning exercise for someone . )

    But there are a number of cases where ` singletons , lists of count 1 , are usefully special cased in a manner similar to scalars . In particular , if one argument is a singleton , it is generally convenient to disclose the result . I generally have variants for variations on the common task . For instance :
    at _at at\ _at\
    for selection with and without disclosure or conversion of raw integer on the stack .

    Anyway modulo indexing generalizes scalar extension , and allows using negatives to index from the end of a list . My philosophy is the machine cycles are there to make my life evermore ` zipless . And it's remarkable how little it slows things down even with no special casing -- at least at my individual level of use .


    Disqus allowed HTML
    comments powered by Disqus


    --

       
    Whole CoSy
    Locations of visitors to this page
    CoSy
     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 /\ /\