Advertisement
TheFastFish

elon-symbols

Apr 11th, 2016
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. symbols
  2. -------
  3. print: Pop a Token, print to standard out
  4. pop: pop a Token, throw it away
  5. dup: copy Token on top
  6. flip: switch the positions of the top two Tokens
  7. wrap: put the top Token into a List
  8. error if already List
  9. unwrap: if a List is top Token
  10. -put all List members onto Stack, remove list
  11. -ex: if Stack is { 123 456 } Stack becomes 123 456
  12. yank: if a List is the top Token
  13. -take the last Token in said List
  14. -put on top of Stack
  15. otherwise error
  16. shove: if a List is the second-to-top Token,
  17. and something that ISN'T a List is the top
  18. -pop Token
  19. -put at end of List below
  20. otherwise error
  21. tie: If top Token is a List of all Strings,
  22. -concat all List members into one long string
  23. -remove List, push new String
  24. untie: if top Token is String,
  25. -convert to List containing each character of String as individual Strings
  26. -ex: if Stack is "ABCDE" Stack becomes { "A" "B" "C" "D" "E" }
  27. count: push Integer of number of Tokens in Stack (not counting this one)
  28. -ex: if Stack is 12 "ayy" then Stack becomes 12 "ayy" 2
  29. sys-info: push List of way more Interpeter state info than you wanted
  30. (you asked for this)
  31. length: push Integer of number of Tokens in List at top of Stack
  32. -if not List do error for bad day
  33. quit: forcibly exit Custom Symbol/List Execute
  34. -if not in then die
  35. end: forcibly exit Interpreter/program
  36. -works anywhere!
  37. define: define a Custom Symbol
  38. -first pops a String telling Symbol name
  39. -next pops a Token
  40. -if Token is List, Symbol becomes an instruction
  41. -when called, List contents are executed as if a program
  42. -ex: { 1 add } "plus-one" define 1 plus-one print end
  43. -prints 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement