mirror of
https://github.com/GayPizzaSpecifications/pork.git
synced 2025-08-03 21:21:33 +00:00
introduce ir nop to fix loop bugs
This commit is contained in:
17
examples/ack.pork
Normal file
17
examples/ack.pork
Normal file
@ -0,0 +1,17 @@
|
||||
/* ackermann function */
|
||||
func ack(m: int32, n: int32): int32 {
|
||||
if m == 0 {
|
||||
return n + 1
|
||||
}
|
||||
|
||||
if n == 0 {
|
||||
return ack(m - 1, 1)
|
||||
}
|
||||
|
||||
return ack(m - 1, ack(m, n - 1))
|
||||
}
|
||||
|
||||
export func main() {
|
||||
let result: int32 = ack(3, 1)
|
||||
println(result)
|
||||
}
|
@ -1,14 +1,7 @@
|
||||
import std ffi.struct
|
||||
|
||||
export let timeval = ffiStructDefine(
|
||||
"long", "seconds",
|
||||
"unsigned int", "microseconds"
|
||||
)
|
||||
|
||||
export let timezone = ffiStructDefine(
|
||||
"int", "minutes_greenwich",
|
||||
"int", "dst_time"
|
||||
)
|
||||
export type timeval = native ffi "long" "seconds" "unsigned int" "microseconds"
|
||||
export type timezone = native ffi "int" "minutes_greenwich" "int" "dst_time"
|
||||
|
||||
func gettimeofday(value, tz)
|
||||
native ffi "c" "int gettimeofday(struct timeval*, struct timezone*)"
|
||||
|
@ -8,6 +8,6 @@ func fib(n: int32): int32 {
|
||||
}
|
||||
|
||||
export func main() {
|
||||
let result: int32 = fib(28)
|
||||
let result: int32 = fib(31)
|
||||
println(result)
|
||||
}
|
||||
|
Reference in New Issue
Block a user