System sort in Turing
Author |
Message |
np_123
|
Posted: Fri May 12, 2017 10:43 am Post subject: System sort in Turing |
|
|
Fellow Turing users, whether you code in Turing as a hobby or for school or whatever, I present to you a beta version of OpenTuring with added sorting capabilities.
WARNING: I have not yet figured out array bounds checking so specifying a second parameter that is greater than the declared array size will produce unexpected behaviour, even crashes. (if anyone knows of a way I can fix this let me know. or if you know of any other Turing proc/fcn that takes in an array I can probably figure it out from there)
Example code for sorting an array of int is as follows:
Turing: |
var x : array 1 .. 10 of int
for i : 1 .. 10
x(i) := 10 - i + 1
end for
Sort.isort(x, 10) % 10 is an int defined as size of array
for i : 1 .. 10
put x(i)
end for
|
Methods are Sort.csort for char, Sort.rsort for real, Sort.ssort for string. Does stability matter? (not sure why it would for primitive types) I provide StableSort.isort, StableSort.csort, StableSort.rsort which are guaranteed to be stable.
*To my knowledge neither Turing nor Open-Turing are currently being actively maintained. I am currently looking into the OpenTuring project to see if reviving or at least further developing it is a feasible undertaking for me. Right now the main thing I lack is knowing how to compile Open Turing such that it can generate standalone executables. If anyone has insight or knows how please let me know.
Description: |
|
Download |
Filename: |
openturing.zip |
Filesize: |
11.81 MB |
Downloaded: |
123 Time(s) |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Insectoid
|
Posted: Fri May 12, 2017 4:32 pm Post subject: RE:System sort in Turing |
|
|
Turing has a length() procedure that returns the size of an array (I think so, anyway). If you can't use that proc directly, you can at least look at its implementation.
Turing is long since dead. Rick Holt, the inventor, gave the source code to one of compsci.ca's users a few years ago with basically no documentation. OpenTuring was spawned from that and made some big improvements to the editor and library but it didn't last very long. If you want to contribute back to the project I suggest you get in touch with him.
|
|
|
|
|
|
np_123
|
Posted: Fri May 12, 2017 11:05 pm Post subject: RE:System sort in Turing |
|
|
yeah, that's my general idea.
it's a shame really because in my opinion Turing was actually decent as an introductory language. Especially as it's statically typed which I think typically encourages better design in inexperienced coders compared to the freedom of Python.
and thanks, i'll look into/for the length() function. that might be what i need.
|
|
|
|
|
|
Insectoid
|
Posted: Sat May 13, 2017 2:50 pm Post subject: RE:System sort in Turing |
|
|
Nothing beats Turing for rapid prototyping of small projects. I still use it over anything else for that reason alone.
|
|
|
|
|
|
|
|