You think you can Turing?
Author |
Message |
chrisbrown

|
Posted: Wed Mar 03, 2010 5:44 pm Post subject: You think you can Turing? |
|
|
Turing: | proc map (fcn f (x : real) : real, var arr : array 0 .. * of real)
for i : 0 .. upper (arr )
arr (i ) := f (arr (i ))
end for
end map
fcn square (x : real) : real
result x ** 2
end square
fcn random (x : real) : real
result Rand.Real ()
end random
proc print (a : array 0 .. * of real)
for i : 0 .. upper (a )
put a (i ), " " ..
end for
put ""
end print
var a : array 0 .. * of real := init (0, 1, 2, 3, 4, 5);
print (a )
map (square, a )
print (a )
map (random, a )
print (a )
% Sadly, this does not work
% map (sin, a)
|
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
DemonWasp
|
Posted: Wed Mar 03, 2010 6:35 pm Post subject: RE:You think you can Turing? |
|
|
Very clever.
Interestingly, if you alias sin as another method, for example sine, it works fine. I wonder why Turing won't let you pass built-in methods around, but will let you pass around your own methods. |
|
|
|
|
 |
TheGuardian001
|
Posted: Wed Mar 03, 2010 7:03 pm Post subject: Re: You think you can Turing? |
|
|
That is pretty weird... I can't see any reason why it wouldn't let you pass a built in function... Wonder if it only opposes the trig commands, or all built in functions... |
|
|
|
|
 |
DtY

|
Posted: Wed Mar 03, 2010 9:07 pm Post subject: Re: RE:You think you can Turing? |
|
|
DemonWasp @ Wed Mar 03, 2010 6:35 pm wrote: Very clever.
Interestingly, if you alias sin as another method, for example sine, it works fine. I wonder why Turing won't let you pass built-in methods around, but will let you pass around your own methods. Probably something to make the language easier to implement. |
|
|
|
|
 |
DemonWasp
|
Posted: Wed Mar 03, 2010 9:14 pm Post subject: RE:You think you can Turing? |
|
|
Ah, laziness, my constant foe. |
|
|
|
|
 |
chrisbrown

|
Posted: Wed Mar 03, 2010 9:34 pm Post subject: RE:You think you can Turing? |
|
|
If you look at the source, all the builtins are external functions, probably written in C++... Turing's creators didn't even want to use their own language!
Side note: haven't touched Turing in 3 years; after learning other languages, you really notice the flaws in this one. |
|
|
|
|
 |
DemonWasp
|
Posted: Wed Mar 03, 2010 9:47 pm Post subject: RE:You think you can Turing? |
|
|
This holds true in all languages - after going somewhere else, you notice the flaws in your old favourites.
Some languages have their faults more apparent up-front, however. |
|
|
|
|
 |
[Gandalf]

|
Posted: Thu Mar 04, 2010 2:02 am Post subject: RE:You think you can Turing? |
|
|
On the other hand, after exploring other languages you begin to understand why Turing was designed the way it was, and why many of its shortcomings exist. |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
|
|