Question: For instance, how can I write code in ATS that traverses a given string as is done by the following C code:

```
while ((c = *str++) != 0) do_something(c);

```

Answer: 
Well, there is always a combinator-based solution:

```
(str).foreach()(lam(c) => do_something(c))

```
The following solution is easy, accessible and doesn't require any unsafe features (but it does use one advanced feature: indexed string type).

```
fun
loop {n:int}(p0: string(n)): void =
if string_isnot_empty (p0) then let
  val c = (g0ofg1)(string_head(p0))
  val p0 = string_tail(p0)
in
  do_something(c); loop(p0)
end

```

Full code: <https://glot.io/snippets/ejpwxk2xzx>