add import feature
This commit is contained in:
7
test/fib/exported
Normal file
7
test/fib/exported
Normal file
@@ -0,0 +1,7 @@
|
||||
fib
|
||||
fn .fib 160 0 1 1
|
||||
0
|
||||
int 1 8 56
|
||||
8
|
||||
int 1 8 0
|
||||
|
||||
8
test/fib/fib.yo
Normal file
8
test/fib/fib.yo
Normal file
@@ -0,0 +1,8 @@
|
||||
package fib
|
||||
|
||||
export fn fib(n int) int {
|
||||
if n <= 1 {
|
||||
return n;
|
||||
};
|
||||
return fib(n-1) + fib(n-2);
|
||||
};
|
||||
BIN
test/fib/obj
Normal file
BIN
test/fib/obj
Normal file
Binary file not shown.
10
test/main.yo
Normal file
10
test/main.yo
Normal file
@@ -0,0 +1,10 @@
|
||||
package main
|
||||
|
||||
import "./test/fib"
|
||||
import "./test/nqueen"
|
||||
|
||||
fn main() int {
|
||||
f := fib.fib(10);
|
||||
n := nqueen.solve(8);
|
||||
return f + n;
|
||||
};
|
||||
7
test/nqueen/exported
Normal file
7
test/nqueen/exported
Normal file
@@ -0,0 +1,7 @@
|
||||
nqueen
|
||||
fn .solve 296 0 1 1
|
||||
0
|
||||
int 1 8 56
|
||||
8
|
||||
int 1 8 0
|
||||
|
||||
@@ -1,27 +1,15 @@
|
||||
package main
|
||||
package nqueen
|
||||
|
||||
type Any struct {
|
||||
x,y int;
|
||||
arr [8]int;
|
||||
export fn solve(n int) int {
|
||||
arr := [16]int{};
|
||||
return nqueen(0, 0, arr[:n]);
|
||||
};
|
||||
|
||||
fn main() int {
|
||||
arr := [8]int{};
|
||||
return nqueen(0, 0, arr[:]);
|
||||
};
|
||||
|
||||
fn fib(n int) int{
|
||||
if n <= 1 {
|
||||
return n;
|
||||
};
|
||||
return fib(n-1) + fib(n-2);
|
||||
};
|
||||
|
||||
fn nqueen(r,ans int, arr []int) int{
|
||||
fn nqueen(r,ans int, arr []int) int {
|
||||
if r == len(arr) {
|
||||
return ans + 1;
|
||||
};
|
||||
for c:=0; c < len(arr); c=c+1{
|
||||
for c:=0; c < len(arr); c=c+1 {
|
||||
arr[r] = c;
|
||||
if canput(r, arr) {
|
||||
ans = nqueen(r+1, ans, arr);
|
||||
BIN
test/nqueen/obj
Normal file
BIN
test/nqueen/obj
Normal file
Binary file not shown.
Reference in New Issue
Block a user