fork download
  1. VARIABLE COUNTER
  2.  
  3.  
  4. : SLOW-COUNT ( -- )
  5.  
  6. 0 COUNTER ! \ 1. Inizializza il contatore
  7.  
  8.  
  9.  
  10. BEGIN
  11.  
  12. KEY? 0= \ 2. Condizione di continuazione: TRUE se NESSUN tasto è premuto
  13.  
  14. WHILE
  15.  
  16. 1 COUNTER +! \ 3. Incrementa il contatore
  17.  
  18.  
  19. CR \ Vai a capo
  20.  
  21. ." Contatore: "
  22.  
  23. COUNTER @ . \ 4. Stampa il valore corrente di COUNTER
  24.  
  25.  
  26.  
  27. 1000 MS \ 5. Aspetta 100 millisecondi per rallentare
  28.  
  29.  
  30.  
  31. REPEAT \ Torna a BEGIN
  32.  
  33.  
  34.  
  35. CR ." Ciclo terminato. Valore finale: " COUNTER @ .
  36.  
  37. ;
  38.  
  39.  
  40. SLOW-COUNT
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
Ciclo terminato. Valore finale: 0