71
loading...
This website collects cookies to deliver better user experience
def fib(int n) -> int :
if n <= 0:
return 1
return fib(n-1) + fib(n-2)
def main():
count = 0 # Peregrine has type inference!
int res = 0
while count < 40:
res = fib(count)
count++
def fib(n):
if n <= 0:
return 1
return fib(n-1) + fib(n-2)
res = 0
for c in range(0, 40):
res = fib(c)
Ccode
allows C code to be ran in Peregrine. Here is an example:def main():
x = 1
Ccode x++; Ccode
print("{x}\n") # prints 2
Ccode
block can be used within Ccode
and vice versa. This also means you can import any C library through Ccode
and use it in Peregrine.def main():
int arg1 = 45
int arg2 = 50
int add = 0
print("It should add 45 and 50 using asm and print it\n")
asm("addl %%ebx, %%eax;" : "=a" (add) : "a" (arg1) , "b" (arg2))
printf("%lld", add)
90
, as expected.