Hi, Marcel,
                      as a first installment on earlier promises, here are
the inverse functions as GForth code:


include random.fs \ need 'rnd' for test

variable (rnd)    \ for marcel's rnd

\ note:  for "dup shift xor," all the inverse functions
\ start with  the original functions

:  turn-around ( n -- n' )   dup 5 lshift xor ;
: -turn-around ( n -- n' )   turn-around
    dup 10 lshift xor  dup 20 lshift xor ;

:  take-off2nd ( n -- n' )   dup 17 rshift xor ;
: -take-off2nd ( n -- n' )   take-off2nd ;

:  take-off1st ( n -- n' )   dup 13 lshift xor ;
: -take-off1st ( n -- n' )   take-off1st       dup 26 lshift xor ;

\ note: here we reverse order for inverses because
\ the lshifts and rshift don't commute
:  take-off    ( n -- n' )    take-off1st  take-off2nd ;
: -take-off    ( n -- n' )   -take-off2nd -take-off1st ;

:  marcel ( -- n )   (rnd) @  take-off    dup  turn-around  (rnd) ! ;
: -marcel ( -- n )   (rnd) @ -turn-around dup -take-off     (rnd) ! ;

: tst   begin  cr rnd ( <-<< time based random number ) dup .
         (rnd) !  marcel dup .  -take-off . -marcel .
\ the check is 1st# = 3rd#  and  2nd# = 4th#
          key 10 = until ;

Reply via email to