Here is some code implementing the Sieve of Erastosthenes. Note that very little type annotation is needed (due to the much stronger support for type-inference in ATS3 than in ATS2)
(* ****** ****** *) fun sieve ( xs : stream(int)) = $lazy ( let val xs = $eval(xs) in case- xs of | strmcon_cons(x0, xs) => strmcon_cons(x0, sieve(filter(xs, x0))) end ) (* end of [sieve] *) and filter(xs, x0) = $lazy ( let val xs = $eval(xs) in case- xs of | strmcon_cons(x1, xs) => ( if (x1%x0=0) then $eval(filter(xs, x0)) else strmcon_cons(x1, filter(xs, x0)) ) end // end of [filter] (* ****** ****** *) val xs = sieve(from(2)) where { fun from (n:int): stream(int) = $lazy(strmcon_cons(n, from(n+1))) } (* ****** ****** *) val- strmcon_cons(x0, xs) = $eval(xs) val- strmcon_cons(x1, xs) = $eval(xs) val- strmcon_cons(x2, xs) = $eval(xs) val- strmcon_cons(x3, xs) = $eval(xs) val- strmcon_cons(x4, xs) = $eval(xs) val- strmcon_cons(x5, xs) = $eval(xs) (* ****** ****** *) (* end of [sieve.dats] *) On Sunday, December 15, 2019 at 9:08:21 PM UTC-5, gmhwxi wrote: > > Hi, there, > > I would like to make a brief announcement, telling those in this group > about some recent progress made in the implementation of ATS3. The > project itself is publicly accessible at the following site: > > https://github.com/githwxi/ATS-Xanadu > > Note that you need to have ATS2 installed in order to compile ATS3. > > So far I have essentially finished the following parts, though changes and > fixes > are definitely needed for a long time to come: > > Part 1: Concrete syntax design + Parsing > Part 2: Binding resolution based on static scoping > Part 3: Type-inference + supporting for symbol overloading > Part 4: Type-based template code selection > > I have also implemented a basic interpreter for testing. > > Compiling ATS3 to C is scheduled in the next phase. After that. advanced > type-checking > (for dependent types and linear types) needs to be supported. > > Before starting the next phase, I plan to write some documentation and > hope to get more > people on board. More on that later. > > Cheers! > > --Hongwei > > > -- You received this message because you are subscribed to the Google Groups "ats-lang-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/8af74c75-aaa4-4c88-bfad-ce0904ba5466%40googlegroups.com.