I don't think there is such a macro constructor
in the Asymptote (it's not a macro language),
but instead we can do something equivalent like
import graph3;
size(9cm);
guide3 loop(int n, triple F(int,int)){
guide3 g;
for (int k=0; k<=n; ++k)g=g..F(k,n);
return g..cycle;
}
draw(
loop(
10,
new triple(int k, int n){return (sin(k),cos(k),sin(k/n));}
)
,red+0.7bp
);
This example uses an anonymous function inside the loop()
call from within the draw()
command,
but there are more options available, for example,
define function(s) to be used explicitly,
or define a special draw()
command,
create a class that will generate and keep
all the points as well as the curve
and a special drawing command, and so on.
Edit:
Perhaps, a closest to the MetaPost construction
would be a one-liner
draw(operator..(...sequence(new triple(int k){return (sin(k),cos(k),sin(k/10));},10))..cycle);
which combines @Charles Staats answer
with the sequence()
command.