roc/examples/jvm-interop/impl.roc
Agus Zubiaga 8dedd9f03c
New app header syntax
Implements the new app header syntax as discussed in Zulip [1].

    app [main] {
	cli: platform "../platform/main.roc",
	json: "../json/main.roc"
    }

Old headers still parse and are automatically upgraded to the new
syntax by the formatter.

[1] https://roc.zulipchat.com/#narrow/stream/304641-ideas/topic/Fewer.2Fdifferent.20keywords.20in.20the.20file.20header/near/418444862
2024-05-01 10:49:01 -03:00

24 lines
640 B
Plaintext

app [program] { pf: platform "platform.roc" }
interpolateString : Str -> Str
interpolateString = \name ->
"Hello from Roc $(name)!!!🤘🤘🤘"
# jint is i32
mulArrByScalar : List I32, I32 -> List I32
mulArrByScalar = \arr, scalar ->
List.map arr \x -> x * scalar
# java doesn't have unsigned numbers so we cope with long
# factorial : I64 -> I64
factorial = \n ->
if n < 0 then
# while we get the chance, exemplify a roc panic in an interop
crash "No negatives here!!!"
else if n == 0 then
1
else
n * (factorial (n - 1))
program = { interpolateString, factorial, mulArrByScalar }