Welcome!
The book was written several years back.
ATS has since evolved a lot. For instance, rtfind could
be implemented as follows in ATS-Temptory:
fn
rtfind
(
f: int -> int
): stream_vt(int) =
(
stream_vt_filter
(sint_streamize_gte(0))
) where
{
impltmp
stream_vt_filter$test<int>(n) = (f(n) = 0)
}
Returning a stream of all the roots of a given function 'f' makes
'rtfind' a lot more flexible.
The "classical" ATS code tends to be like code in C or ML. Newer ATS code
emphasizes a lot more on "batch-processing". Please find some explanation
and documentation in the following directory and also some coding examples:
https://github.com/githwxi/ATS-Temptory/tree/master/docgen
On Saturday, June 1, 2019 at 1:12:35 AM UTC-4, Srdjan Mitrovic wrote:
>
> Hi! First time using both google groups and ATS, so forgive me if this is
> a really dumb question or the wrong spot but this seems like the best place
> to get in contact with other ATS people :p
>
> I'm working through the intro to programming in ATS book, and in this
> section
> <http://ats-lang.sourceforge.net/DOCUMENT/INT2PROGINATS/HTML/x746.html> it
> says that you should denote functions which use a value not at the top
> level nor in the function arguments with <cloref1>.
> In the next section on higher order functions, there's a function which is
> supposed to find the first natural number root of a given polynomial. The
> example given looks like this:
>
> fun rtfind
> (f: int -> int): int = let
> fun loop (
> f: int -> int, n: int
> ) : int =
> if f(n) = 0 then n else loop (f, n+1)
> // end of [loop]
> in
> loop (f, 0)
> end // end of [rtfind]
>
> I was a little curious, so I removed `f` from the inner `loop` function
> and re-compiled, curious to see if I would get an error for having not
> included <cloref1>
>
>
> fun rtfind
> (f: int -> int): int = let
> fun loop (
> n: int
> ) :(* <cloref1> *) int =
> if f(n) = 0 then n else loop (n+1)
> in
> loop (0)
> end
>
> As it is, this works fine, but what I found more surprising was that
> uncommenting <cloref1> results in this:
>
> [image: cloref1.png]
>
>
>
>
>
> am I missing something here? I have atspre_staload.hats included in my
> file fwiw
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/a9e5846f-cceb-44b7-86e0-4544071e418a%40googlegroups.com.