MoreMathRPN/Implicit plotter

From Esolang
Jump to navigation Jump to search

← go back
Using Matrices in neat ways, you can graph any function in the output

"x^2-y^2-2=0
chars "place x\n>> 0\n*\nplace y\n>> 0\n*\n-\n2\n-"
hold f
del 0
m $f 1
flip
hold f
del 0
5.1
hold y
del 0
-1
m 1 1
repeat 52
 >>> 0
 26.5
 -
 5
 /
 hold x
 del 0
 place f
 run
 0
 compare
 m 1 1
 aug
next
flip
rip
del 0
flip
T
repeat 51
 25.5
 >>> 0
 -
 5
 /
 hold y
 del 0
 -1
 m 1 1
 repeat 52
  >>> 0
  26.5
  -
  1/5
  *
  hold x
  del 0
  place f
  run
  0
  compare
  m 1 1
  aug
 next
 flip
 rip
 del 0
 flip
 T
 aug
 repeat 51
  >>> 0
  >> 0
  1
  -
  -> 2
  ind 0 ]1
  <- 3
  ind 1 ]1
  <- 3
  ind 0 ]2
  <- 3
  ind 1 ]2
  del 2
  del 2
  repeat 3
   -> 2
   >> 1
   0
   compare
   >> 0
   *
   4
   *
   jmp ]0
    del 1
    del 1
    jmp 17
   del 0
   >> 0
   0
   compare
   >> 0
   *
   4
   *
   jmp ]0
    del 1
    del 1
    jmp 5
   del 0
   +
   2
   /
  next
  >> 0
  *
  4
  *
  jmp ]0
   "crossing
   del 0
   outputS "#"
   jmp 39
  del 0
  >>> 0
  26
  compare
  >> 0
  *
  16
  *
  jmp ]0
   "x=0
   del 0
   >>> 1
   26
   compare
   >> 0
   *
   4
   *
   jmp ]0
    "y=0
    del 0
    outputS "+"
    jmp 18
   del 0
   outputS "|"
   jmp 15
  del 0
  >>> 1
  26
  compare
  >> 0
  *
  4
  *
  jmp ]0
   "y=0
   del 0
   outputS "-"
   jmp 3
  del 0
  outputS " "
 next
 outputS "\n"
 rip
 del 1
next

Produces the following output:

#                        |                        #
#                        |                        #
##                       |                       ##
 ##                      |                      ## 
  ##                     |                     ##  
   ##                    |                    ##   
    ##                   |                   ##    
     ##                  |                  ##     
      ##                 |                 ##      
       ##                |                ##       
        ##               |               ##        
         ##              |              ##         
          ##             |             ##          
           ##            |            ##           
           ##            |            ##           
            ##           |           ##            
             ##          |          ##             
              ##         |         ##              
               #         |         #               
               ##        |        ##               
                ##       |       ##                
                 #       |       #                 
                 ##      |      ##                 
                 ##      |      ##                 
                  #      |      #                  
------------------#------+------#------------------
                  #      |      #                  
                 ##      |      ##                 
                 ##      |      ##                 
                 #       |       #                 
                ##       |       ##                
               ##        |        ##               
               #         |         #               
              ##         |         ##              
             ##          |          ##             
            ##           |           ##            
           ##            |            ##           
           ##            |            ##           
          ##             |             ##          
         ##              |              ##         
        ##               |               ##        
       ##                |                ##       
      ##                 |                 ##      
     ##                  |                  ##     
    ##                   |                   ##    
   ##                    |                    ##   
  ##                     |                     ##  
 ##                      |                      ## 
##                       |                       ##
#                        |                        #
#                        |                        #