[Swift-user] two questions about Swift (fwd)

Justin M Wozniak wozniak at mcs.anl.gov
Mon Mar 1 15:30:03 CST 2010


Hello Yi
 	If you can check out the latest Swift from trunk I've added some 
features that might help you out here.  There's a new built-in function @java() 
that allows you to call into an existing Java library.  You can call into the 
Java Platform or into your CLASSPATH.
 	Here is one example:

(float result) sin(float x) {
   result = @java("java.lang.Math", "sin", x);
}

float x = 0.5;
float y = sin(x);

trace("sin", x, y);

Note that you currently have to assign the result of @java() to a variable.

On Tue, 16 Feb 2010, Michael Wilde wrote:

>>>> Yi, sorry - I missed these questions from you; just saw them now.
>>>> 
>>>> ----- "Yi Zhu" <yizhu at cs.uchicago.edu> wrote:
>>>> 
>>>>> Hi all
>>>>> 
>>>>> 2.  In Matlab, there are some library which support some Math 
>>>>> functions like "sin" "cos" "reshape" etc. Is there any similar 
>>>>> library available for swift. If not, is there anyway to import 
>>>>> external library? (e.g. from Java)

-- 
Justin M Wozniak



More information about the Swift-user mailing list