Skip to content

Commit

Permalink
Clarify .docs/SNIPPET.txt, with better format and added expect statem…
Browse files Browse the repository at this point in the history
…ent (#48)
  • Loading branch information
ageron authored Aug 28, 2024
1 parent d7011d2 commit 841418a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions docs/SNIPPET.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.14.0/dC5ceT962N_4jmoyoffVdphJ_4GlW3YMhAPyGPr-nU0.tar.br" }

import pf.Stdout

factorial = \n ->
if n == 1 then
1
else
n * factorial (n - 1)
factorial = \number ->
when number is
1 -> 1
n -> n * factorial (n - 1)

expect factorial 5 == 1 * 2 * 3 * 4 * 5

main =
result = factorial 5
Stdout.line! "factorial 5 = 1 * 2 * 3 * 4 * 5 = $(Num.toStr result)"
result = factorial 20 |> Num.toStr
Stdout.line! "factorial 20 = $(result)"

0 comments on commit 841418a

Please sign in to comment.