ATSLIB/prelude/intrange
Synopsis
fun{}
intrange_foreach (l: int, r: int): int
Description
Given two integers l and r, this function enumerates the integers between l
and r-1, inclusive, and then applies to each enumerated integer the
function implemented by intrange_foreach$fwork. The enumeration
process stops if the function implemented by intrange_foreach$cont
returns false, and the integer value returned by intrange_foreach
indicates the point of the stoppage.
Synopsis
fun{env:vt0p}
intrange_foreach_env (l: int, r: int, env: &(env) >> _): int
Description
This function does essentially the same as intrange_foreach
except for taking an additional argument that serves as an environment. Example
The following code implements a function for constructing a list
of randomly generated values:
staload R = "contrib/libats-hwxi/testing/SATS/randgen.sats"
fun{a:t@ype}
list_randgen
(n: int): List0_vt (a) = let
viewtypedef env = List0_vt (a)
implement
intrange_foreach$fwork<env>
(_, env) = env := list_vt_cons ($R.randgen_val<a> (), env)
var res: env = list_vt_nil ()
val _ = intrange_foreach_env<env> (0, n, res)
in
res
end
Synopsis
fun{env:vt0p}
intrange_foreach$cont (i: int, env: &env): bool
Description
The default implementation of this function always returns true.
Synopsis
fun{env:vt0p}
intrange_foreach$fwork (i: int, env: &(env) >> _): void
Description
By default, this function is unimplemented.
Synopsis
fun{}
intrange_rforeach (l: int, r: int): int
Description
Given two integers l and r, this function enumerates in the reverse order
the integers between l and r-1, inclusive, and then applies to each
enumerated integer the function implemented by
intrange_rforeach$fwork. The enumeration process stops if the
function implemented by intrange_rforeach$cont returns false,
and the integer value returned by intrange_rforeach indicates
the point of stoppage.
Synopsis
fun{env:vt0p}
intrange_rforeach_env (l: int, r: int, env: &(env) >> _): int
Description
This function does essentially the same as intrange_rforeach
except for taking an additional argument that serves as an environment.
Synopsis
fun{env:vt0p}
intrange_rforeach$cont (i: int, env: &env): bool
Description
The default implementation of this function always returns true.
Synopsis
fun{env:vt0p}
intrange_rforeach$fwork (i: int, env: &(env) >> _): void
Description
By default, this function is unimplemented.