Execute SNUSP/F Sharp: Difference between revisions

Content added Content deleted
m (A little more work)
m (Categorization now in master page)
Line 1: Line 1:
{{implementation|SNUSP}}{{collection|RCSNUSP}}[[Category:F Sharp]]
{{implementation|SNUSP}}{{collection|RCSNUSP}}
This is the "modular" version. Perhaps I'll get around to bloated later. Allows infinite size data space to the left and right of the original data pointer. I originally mistook the meaning of ',' and had the user input an arbitrary number which I would place on the tape, but after looking at the sample multiplication program, realized that I was supposed to input the ascii value of the single key entered. Still, it seems like a good command to allow for reading an arbitrary value so I arbitrarily allocated '~' as the command for that purpose.
This is the [[F Sharp|F#]] implementation of the "modular" version. Perhaps I'll get around to bloated later. Allows infinite size data space to the left and right of the original data pointer. I originally mistook the meaning of '<code>,</code>' and had the user input an arbitrary number which I would place on the tape, but after looking at the sample multiplication program, realized that I was supposed to input the ascii value of the single key entered. Still, it seems like a good command to allow for reading an arbitrary value so I arbitrarily allocated '<code>~</code>' as the command for that purpose.


Bloated version below this modular version. Somehow this page has been set up so I can't seem to change the original comments to note this fact. Probably I'm just too dumb to know now.
Bloated version below this modular version. Somehow this page has been set up so I can't seem to change the original comments to note this fact. Probably I'm just too dumb to know now.
Line 132: Line 132:
(!input).[!ptr]</lang>
(!input).[!ptr]</lang>
==Bloated SNUSP==
==Bloated SNUSP==
Okay, I did the bloated version and made a few other changes. Using * rather than ~ for inputting a number because it's easy for ~ to get lost in the visual sea of characters that makes up the typical program. Also made separate classes for the engine and the IP. I allow for infinite data space in both directions and threads not waiting for input run while other threads are blocked on input. I tried this on all the programs I could find. There don't appear to be any which really utilize the 2D data space, but I tested it with some simple test programs and it seems okay.
Okay, I did the bloated version and made a few other changes. Using <code>*</code> rather than <code>~</code> for inputting a number because it's easy for <code>~</code> to get lost in the visual sea of characters that makes up the typical program. Also made separate classes for the engine and the IP. I allow for infinite data space in both directions and threads not waiting for input run while other threads are blocked on input. I tried this on all the programs I could find. There don't appear to be any which really utilize the 2D data space, but I tested it with some simple test programs and it seems okay.
<lang fsharp>// Bloated RCSNUSP
<lang fsharp>// Bloated RCSNUSP
open System
open System
Line 375: Line 375:
let snusp = new SNUSP(pgm) // Create an engine
let snusp = new SNUSP(pgm) // Create an engine
snusp.Execute() // and run the program with it
snusp.Execute() // and run the program with it
snusp.ReturnValue() // Return the return value
snusp.ReturnValue() // Return the return value</lang>
</lang>


==Example Inputs==
==Example Inputs==
Line 419: Line 418:
\!\/\/\/
\!\/\/\/
")
")
printfn "value = %d" (RCSNUSP @"6=@@@+@+++++#")
printfn "value = %d" (RCSNUSP @"6=@@@+@+++++#")</lang>
</lang>