mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-19 01:59:48 +00:00
stabilize record usage in requires, add examples
This commit is contained in:
parent
8e40725d25
commit
94f9c6712d
4 changed files with 90 additions and 62 deletions
|
@ -1,15 +1,39 @@
|
|||
package javaSource;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Demo {
|
||||
|
||||
static {
|
||||
System.loadLibrary("interop");
|
||||
}
|
||||
|
||||
public static native String sayHello(String num);
|
||||
// public static native int[] mularr(int[] arr);
|
||||
|
||||
public static native int[] mulArrByScalar(int[] arr, int scalar);
|
||||
|
||||
public static native long factorial(long n);
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(sayHello("Brendan"));
|
||||
// int[] arr = {10, 20, 30, 40};
|
||||
// System.out.println(mularr(arr));
|
||||
|
||||
// string demo
|
||||
System.out.println(sayHello("Brendan") + "\n");
|
||||
|
||||
// array demo
|
||||
int[] arr = {10, 20, 30, 40};
|
||||
int x = 3;
|
||||
System.out.println("Array " + Arrays.toString(arr) +
|
||||
" multipled by " + x +
|
||||
" results in " + Arrays.toString(mulArrByScalar(arr, x)) +
|
||||
"\n");
|
||||
|
||||
// number + panic demo
|
||||
// This can be implemented more peacefully but for sake of demonstration-
|
||||
// this will panic from the roc side if n is negative
|
||||
// and in turn will throw a JVM RuntimeException
|
||||
long n = -1;
|
||||
System.out.println("Factorial of " + n + " is " + factorial(n) + "\n");
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue