newRPL - build 1255 released! [updated to 1299]
|
02-05-2020, 01:07 PM
(This post was last modified: 02-05-2020 01:20 PM by 3298.)
Post: #639
|
|||
|
|||
RE: newRPL - build 1255 released! [updated to 1299]
(02-04-2020 07:24 PM)compsystems Wrote: In previous post it is mentioned that the library or graphic module of NewRPL is in development, I think it is a good idea to give some compatibility with names and argument of the MatPlotLib et Turtle libraryYou seem to have forgotten (again!) that these commands are extremely unlikely to be builtin due to their utter lack of usefulness to the general programmer and engineer (which the 50g has always been made for), instead requiring you to implement them. That also means YOU get to choose what their names are. In short: Claudio's work on such compatibility is done already, and it has been since user programs could be written and named (i.e. for several years). --- Since you seem to be incapable of actually implementing something rather than merely tossing ridiculous suggestions for your wanted builtin commands around, let me show you some code that demonstrates how trivial implementing your turtle commands in RPL really is. For this I'm using for the most part very basic RPL functionality (stack juggling, global variables, IF ... THEN ... END, a little bit of trig and arithmetic operators, units to work with angle modes), the command LINE from old UserRPL (i.e. a single really elementary graphics command), and a little bit of complex numbers which LINE uses for coordinates. This means that as soon as LINE is implemented in newRPL, this should all just work. Let's start with "goto". The purpose of "goto" is to update the stored position of the cursor (a.k.a. the turtle) to the given coordinates, and draw a line between the previous and new position if drawing is enabled (a.k.a. the pen is down), right? If so, try this: Code: « i * + IF turtlepen THEN turtlepos OVER LINE END 'turtlepos' STO » Code: « turtledir COS OVER * turtlepos RE + turtledir SIN ROT * turtlepos IM + goto » Code: « 1._° CONVERT turtledir + 'turtledir' STO » Code: « 1. 'turtlepen' STO » Now, for your home assignment: Implement "right" and "penup" yourself. You can use "left" and "pendown" as templates. Also, implement an initialization program that sets the global variables used in this set of programs (turtlepos, turtledir, turtlepen) to some sane defaults and turns off obstructions like axes and their labels. With these commands, the RPL version (because newRPL is obviously all about RPL) of that example you lazily grabbed off the internet becomes: Code: « |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)