fork(1) download
  1. GET-CURRENT
  2. VOCABULARY points
  3. points DEFINITIONS
  4. ALSO
  5. : x ( p -- x ) @ ;
  6. : y ( p -- y ) CELL+ @ ;
  7. : draw ( p -- ) DUP x SWAP y CR ." Draw point" ." x=" . ." y=" . PREVIOUS ;
  8. PREVIOUS
  9. SET-CURRENT
  10.  
  11. GET-CURRENT
  12. VOCABULARY circles
  13. circles DEFINITIONS
  14. ALSO
  15. : x ( p -- x ) @ ;
  16. : y ( p -- y ) CELL+ @ ;
  17. : radius ( p -- radius ) CELL+ CELL+ @ ;
  18. : draw ( p -- ) DUP x OVER y ROT radius CR ." Draw circle x=" . ." y=" . ." radius= " . PREVIOUS ;
  19. PREVIOUS
  20. SET-CURRENT
  21.  
  22. : POINT ( x y -- p ) CREATE , , DOES> ALSO points ;
  23. : CIRCLE ( x y radius -- p ) CREATE , , , DOES> ALSO circles ;
  24.  
  25. 10 20 POINT p
  26. 30 40 50 CIRCLE c
  27.  
  28. p draw \ draw point
  29. c draw \ draw circles
  30.  
  31. : draw_point p [ ALSO points ] draw [ PREVIOUS ] ;
  32. : draw_circle c [ ALSO circles ] draw [ PREVIOUS ] ;
  33. draw_point
  34. draw_circle
  35.  
Success #stdin #stdout 0.02s 7504KB
stdin
Standard input is empty
stdout
Draw pointx=10 y=20 
Draw circle x=30 y=40 radius= 50 
Draw pointx=10 y=20 
Draw circle x=30 y=40 radius= 50