while  ( fl -- )

published: 18 January 2022 / updated 16 February 2022

Lire cette page en français

 

vocabulary: forth

Mark the conditionnal part execution of a structure begin..while..repeat

Example:

\ logarithmus dualis of n1>0, rounded down to the next integer 
: log2 ( +n1 -- n2 ) 
    2/ 0 begin 
        over 0 >  
    while 
        1+ swap 2/ swap 
    repeat 
    nip  
  ; 
  7 log2 .     \ display 2 
100 log2 .     \ display 6 

Legal: site web personnel sans commerce / personal site without seling