forth.joy 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. (* forth.joy -- Forth-isms for Joy.
  2. Copyright © 2016 Eric Bavier <bavier@member.fsf.org>
  3. Joy is free software; you can redistribute it and/or modify it under
  4. the terms of the GNU General Public License as published by the Free
  5. Software Foundation; either version 3 of the License, or (at your
  6. option) any later version.
  7. Joy is distributed in the hope that it will be useful, but WITHOUT
  8. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  9. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  10. License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with Joy. If not, see <http://www.gnu.org/licenses/>.
  13. *)
  14. "base" include
  15. DEFINE
  16. drop == pop ;
  17. over == dupd swap ;
  18. nip == popd ;
  19. tuck == dup swapd ;
  20. rot == dig2 ;
  21. -rot == bury2 ;
  22. pick == stack rest swap at ;
  23. /mod == divmod ;
  24. within == [dupd >] dip swap [<] dip and ;
  25. within? == succ within ;
  26. cr == newline ;
  27. bl == " " first ;
  28. emit == putch ;
  29. END