prelude.mrth 996 B

12345678910111213141516171819202122232425
  1. { A selection of generally-useful functions. Each much be defined
  2. with only primitives, since variables might be expanded after being
  3. redefined be users. }
  4. [[!][12012]@[#]++*+[!]_?][#]: { while }
  5. [[])]N: { newstack }
  6. [[%]_]p: { popd }
  7. [%%]P: { pop2 }
  8. [[0101]@]D: { dup2 }
  9. [[210]@]r: { rot }
  10. [[120]@]b: { bury2 }
  11. [[201]@]d: { dig2 }
  12. [25*,]n: { newline }
  13. [48*,]s: { space }
  14. { [[[25*][%]]
  15. [[48*][%]]
  16. [$]]c;! "case"}
  17. [$[]=$~\
  18. [[%]_]? { if empty, consume input and do nothing }
  19. [$0[[[]=~]_][1+[-\%]_]# { get length of input }
  20. 2<$~
  21. [[-[--%[![$]_=]_?]_c;!]?]_ { compare, execute, and recurse }
  22. [-%!]? { if singleton then default case }
  23. ]?]c: { case }