[Swift-user] two questions about Swift
Hodgess, Erin
HodgessE at uhd.edu
Tue Feb 16 11:42:16 CST 2010
You can use R, the stat program. That works with Swift.
There is a tutorial that Mike can point you to.
Thanks,
Erin
Erin M. Hodgess, PhD
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: hodgesse at uhd.edu
-----Original Message-----
From: swift-user-bounces at ci.uchicago.edu on behalf of wilde at mcs.anl.gov
Sent: Tue 2/16/2010 11:12 AM
To: Yi Zhu
Cc: swift-user at ci.uchicago.edu
Subject: Re: [Swift-user] two questions about Swift
Yi, sorry - I missed these questions from you; just saw them now.
----- "Yi Zhu" <yizhu at cs.uchicago.edu> wrote:
> Hi all
>
> I have two questions about swift:
>
> 1. conventional loop: In swift, we can use foreach to parallel apps,
>
> but what If I just need a conventional loop, like a regular "for" or
> "while" in java?
No, thats somewhat limited at the moment. We can consider this for future revisions. There were a variety of differing views on what control statements Swift should offer.
>
> 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)
I have experimented with techniques for building a library of useful functions by using simple app() functions that do their work using a variety of shell commands and scripts.
Pasted below is one of my experiments; Im not sure if all the functions in it work, but it should serve as a guide for *one* way of doing this.
At the same time, a guide for extending the set of built-in primitives would be useful as well, as these can bend the data typing rules in useful ways, whereas the app() approach to building lib functions can not (so you often wind up with a lot fo explicit "casting" functions to e.g. jump between numbers and strings).
- Mike
---
login1$ cat stringlib.swift
type file;
// Lib functions
app (file o) echoi (int i) { echo i stdout=@o;}
app (file o) echof (float f) { echo f stdout=@o;}
app (file o) echob (boolean b) { echo b stdout=@o;}
app (file o) echos (string s) { echo s stdout=@o;}
(string s) itostr (int i)
{
file f;
f = echoi(i);
s = readData(f);
}
(string s) ftostr (float n)
{
file f;
f = echof(n);
s = readData(f);
}
(float n) strtof (string s)
{
file f;
f = echos(s);
n = readData(f);
}
app (file o) sprintfsApp (string fmt, string e[])
{
sprintfs fmt e stdout=@o;
}
(string s) sprintfs (string fmt, string e[])
{
file f;
f = sprintfsApp(fmt,e);
s = readData(f);
}
// Tests
test_sprintf()
{
string s0 = sprintfs("%.10d",["123"]);
trace(s0);
string s1 = sprintfs("input/protein.%s.%.10d",["T1ubq",itostr(123)]);
trace(s1);
string s2 = sprintfs("n=%.4e",[ftostr(3.34e06)]);
trace(s2);
}
test_converters()
{
float f = strtof("123.456");
trace("strtof(123.456)", f);
}
test_converters();
login1$ swift stringlib.swift
Swift svn swift-r3202 cog-r2683
RunID: 20100216-1108-mg4uz0v7
Progress:
SwiftScript trace: strtof(123.456), 123.456
Final status: Finished successfully:1
login1$
>
> Many Thanks.
>
>
> -Yi
>
>
> _______________________________________________
> Swift-user mailing list
> Swift-user at ci.uchicago.edu
> http://mail.ci.uchicago.edu/mailman/listinfo/swift-user
_______________________________________________
Swift-user mailing list
Swift-user at ci.uchicago.edu
http://mail.ci.uchicago.edu/mailman/listinfo/swift-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/swift-user/attachments/20100216/b9baeaa7/attachment.html>
More information about the Swift-user
mailing list