From: minforth@gmx.net   
      
   Am 23.09.2025 um 19:23 schrieb Anton Ertl:   
   > minforth writes:   
   >> FWIW I also use suffixes for recognizers:   
   >> let M be a matrix   
   >> M´ auto-transposed   
   >> M~ auto-inverted   
   >   
   > Can you give an example of a matrix with your matrix recognizer?   
   >   
      
   To be fair, here MinForth displays the matrix/vector stack in the   
   QUIT prompt:   
      
   MinForth 3.6 (64 bit) (fp matrix)   
   # 0 0 matrix mat ok   
   # m[ 1 2 3 ; 4 5 6 ] ok   
   M: <1>   
   [ 1 2 3 ; 4 5 6 ]   
   # to mat ok   
   # mat' ok   
   M: <1>   
   [ 1 4 ; 2 5 ; 3 6 ]   
   # m[ 1 2 3 ; 4 5 6 ; 4 3 -2 ] := mat ok   
   M: <1>   
   [ 1 4 ; 2 5 ; 3 6 ]   
   # mat~ ok   
   M: <2>   
   [ -2.333333 1.083333 -0.25 ; 2.666667 -1.166667 0.5 ; -0.6666667   
   0.4166667 -0.25 ]   
   [ 1 4 ; 2 5 ; 3 6 ]   
   # m.   
   [ -2.33333 1.08333 -0.25   
    2.66667 -1.16667 0.5   
    -0.666667 0.416667 -0.25 ] ok   
   M: <1>   
   [ 1 4 ; 2 5 ; 3 6 ]   
   #   
      
   The implementation won't help you at all because I use my own   
   recognisers. Tt's an eye sore ;-)   
      
   \ ------ Matrix/Vector Indexing ------   
      
   \ Syntax: ( for positional indexing   
   D: _[MVAL] i" mfmx=(mfMx*)mfpop(), mfmd=mfpop();" ;   
   D: _MVAL [,] depth i" mfpush(mfmx);" [,] literal [,] _[mval] ;   
      
   \ Syntax: ^ for heap addressing   
   : _MVAL^ i" mfpush(mfmx->dat);" ;   
   : _[MVAL^] _mval^ [,] literal ;   
      
   \ Syntax: ' for implicit transposing   
   : _MVAL' i" mfmup, mfm_set(mfmtos,mfmx), mfm_trans(mfmtos);" ;   
   : _[MVAL'] _mval [,] _mval' ;   
      
   \ Syntax: ~ for implicit inversion   
   : _MVAL~ i" mfmup, mfm_set(mfmtos,mfmx), mfm_inv(mfmtos);" ;   
   : _[MVAL`] _mval [,] _mval~ ;   
      
   : __MXLITERAL? \ ( -- .. t | f ) recognize different matrix calls   
    _parsed 2@ 1- _find-word IF dup cell+ @ _vmxmethods = IF   
   C mfmx=(mfMx*)((mfpop())+2*MFSIZE), mfmd=mfsp-mfstk;   
    _parsed 2@ 1- + c@   
    dup '(' = IF drop ['] noop ['] _mval true EXIT THEN   
    dup '^' = IF drop ['] _mval^ ['] _[mval^] true EXIT THEN   
    dup ''' = IF drop ['] _mval' ['] _[mval'] true EXIT THEN   
    '~' = IF ['] _mval~ ['] _[mval~] true EXIT THEN   
    ELSE drop THEN THEN deferred _literal? ;   
   IS _LITERAL?   
      
   \ ------   
      
   _LITERAL? is a deferrable element in the recognizer chain which   
   is called in the INTERPRET loop (it is also used to recognize   
   floats and complex numbers).   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|