Well, it turns out that the 'map' function in Perl uses an anonymous variable behind the scenes.
So in the end, it uses a variable after all, we could consider this cheating....?
print sin for(1..1000) doesn't use
map.
But, you're right - it uses the
$_ variable which is used by default (you don't need to type it). And the original task was
Write a program that writes on the screen values of sinus for numbers form 1 to 100 without using any variable name. To be honest I posted it as an example of a task that is to specific and constructed the way that makes certain language (Perl in this case) an automatic winner. But, was I right? I'm not sure anymore.
ok
print sin for(1..1000);
is that work without two points ?
(1..1000)
i think not ..so this is just ordinary predefined for-Loop
Yes, it is. What's wrong with that? Did anyone say that loops were not allowed?
(1..1000) is a range of integers between 1 and 1000. You could also write it like that:
for [$_] (1..1000) {
print sin([$_]);
}
$_ is used by default if the other variable name is not specified, so you don't have to write it. Unfortunately, ranges in Perl don't allow to define step, so, to get sinuses of numbers from 1 to 1000 step 0.1, you would have to write something like this:
print sin for (map {$_ / 100} (1..100000))
I thik that in this case Newlisp wins.
Okay, I get it now. SIN() range with no variables used.
Have fun!
Any task that ScriptBasic fail to complete is automatically a stupid one?