Advertisement
Imgoodisher

Befunge Example Programs

Feb 3rd, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. local examples = {
  2. ["helloworld"] = [[>0"!dlrow ,olleH" :v
  3. v:,_@
  4. > ^
  5.  
  6.  
  7. Notice the >, <, v, and ^ instructions changing
  8. the direction the pointer is moving
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20. <-- You can see the letters here]],
  21. ["random"] = [[v>>>>.
  22. s12345
  23. ^?^ In this program, the pointer goes to the
  24. > ? ?^ end of the program. When this happens, it
  25. v?v wraps back to the beginning
  26. v6789>
  27.  
  28. It also uses the ? instruction, which
  29. changes the pointer to move in a random
  30. direction
  31. ]],
  32. ["add"] = [[> v
  33. v"a> "<
  34. >,,,& v Notice that the program waits for an
  35. v"b> "< input at the '&' symbol
  36. >,,,& v
  37. v"output> "<
  38. > ,,,,,,,, +.@
  39.  
  40. ]],
  41. ["chars"] = [[v
  42. 1
  43. >1+:,v
  44. ^ s <
  45. ]],
  46. }
  47.  
  48. print("Available Programs:")
  49. fs.makeDir("/examples")
  50. for i,v in pairs(examples) do
  51. file = io.open("/examples/"..i, "w")
  52. file:write(v)
  53. file:close()
  54. print(" - "..i)
  55. end
  56. print("Your example programs are in /examples/<programname>")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement