Stream: beginners

Topic: print list


view this post on Zulip itmuckel (Mar 17 2023 at 14:34):

How do I print a list with Stdout.line?

view this post on Zulip Brendan Hansknecht (Mar 17 2023 at 14:38):

What is the list of?

Currently we have no display type feature for converting a list to a string. We do have dbg if you just want a short live debug print out.

In general, map the list element type to a string. Then join it together with commas or similar.

For numbers could do List map Num.toStr |> Str.joinwith ", " |> Stdout.Line

view this post on Zulip itmuckel (Mar 17 2023 at 14:43):

perfect, that did it, thanks! Also is there no variable shadowing in roc? I had a global list l and then I had a function with an l parameter and that collided somewhow.

── DUPLICATE NAME ─────────────────────────────────────────────────── test.roc ─

The l name is first defined here:

7│  l = [1, 2, 3, 4, 5]
    ^

But then it's defined a second time here:

16│  walk = \l ->
             ^

Since these variables have the same name, it's easy to use the wrong
one by accident. Give one of them a new name.

────────────────────────────────────────────────────────────────────────────────

1 error and 1 warning found in 1604 ms while successfully building:

view this post on Zulip Brendan Hansknecht (Mar 17 2023 at 14:50):

Yeah, no shadowing at all in roc. Have to change the name of one of them


Last updated: Jul 06 2025 at 12:14 UTC