Re: Loops

"Buday, Gergely Istvan" <[email protected]>
Newsgroups gmane.comp.lang.sml.smlnj
Message-ID <89AE2DBAB3A9E943A358F9780F266AC37E9412@budgw09a.ww300.siemens.net>
Mr. Noname writes:

> I was wondering if SML can envoke an iterative loop ( i.e 
> while (...) do ...
> od ), 
> 
> or are all loops strictly recursive ( gnu ).

Paulson writes

"For iteration, ML has a while command:

	while E1 do E2

[...]

To be precise, the while command satisfies the recursion

   while E1 do E2 = if E1 then (E2; while E1 do E2)
                          else ()

"

Because of type-checking, E2 must be evaluated to unit. Usually one uses
refs to count.

But why you exactly need a while loop? For aggregate data structures
(lists, arrays, vectors) there are proper functions that releave the
burden of checking bounds.

- Gergely

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.