Stream: beginners

Topic: Arithmetic Operations


view this post on Zulip Chloe Bai (Oct 03 2024 at 14:57):

hi!! would someone be able to provide some code examples of arithmetic operations with correct roc file formatting. i'm really struggling to find the documentation for format and correct syntax.

view this post on Zulip Chloe Bai (Oct 03 2024 at 14:59):

right now i have this:

Num.sub 5000 30000

but i think the file needs a header and i'm not sure how to set that up? when i do

cargo run -- crates/cli/tests/subtraction_test.roc

it gives me this error:
thread 'main' panicked at crates/reporting/src/error/parse.rs:3937:14:
not yet implemented: unhandled exposes parsing error ListStart(@7)
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

view this post on Zulip Brendan Hansknecht (Oct 03 2024 at 15:01):

We have lots of basic mathematics tests in gen_num.rs

view this post on Zulip Brendan Hansknecht (Oct 03 2024 at 15:02):

https://github.com/roc-lang/roc/blob/main/crates/compiler/test_gen/src/gen_num.rs

view this post on Zulip Chloe Bai (Oct 03 2024 at 15:10):

thank you!

view this post on Zulip Chloe Bai (Oct 03 2024 at 15:33):

@Brendan Hansknecht do you know how i format the header of a file?

view this post on Zulip Brendan Hansknecht (Oct 03 2024 at 15:46):

Yeah, I would just take the header from one of the neighboring files or examples. For example, if you want a simple CLI app for testing, I would just base it of the hello world example

view this post on Zulip Brendan Hansknecht (Oct 03 2024 at 15:47):

https://github.com/roc-lang/roc/blob/main/examples/helloWorld.roc

view this post on Zulip Chloe Bai (Oct 03 2024 at 15:47):

thank you, appreciate it!!


Last updated: Jul 05 2025 at 12:14 UTC