[Prev][Next][Index][Thread]

Re: multiple values in a return from function



In article <30Mo4.10657$pH6.368416@newsread1.prod.itd.earthlink.net>,
"John Whittaker" <johncwhi@earthlink.net> wrote:

> I'm not sure what I'm doing wrong here.  I wanted to return two values from
> a function that computes solar positions--the right ascension and
> declination of the sun.  Both are <floats>.  When I tried interactively
> testing this function, it would only return 1 value.

It should work fine, but you don't show how you're testing it.

[interpreter thread starting.]
Marlais 0.5.11
? define method sincos(a)
>  values(sin(a), cos(a))
> end;
==> sincos
? define variable (x, y) = sincos(3.141592654/6);;
? x;
==> 0.500000
? y;
==> 0.866025
? 


Note that the *only* ways to make use of multiple return values are to
assign them to variables using either "define variable (foo, bar, baz) = "
or else "let (foo, bar, baz) = ".  Any other method of using the function
return will ignore all but the first value.

-- Bruce



References: