Skip to content

Commit

Permalink
update fib function
Browse files Browse the repository at this point in the history
  • Loading branch information
linsyking committed Apr 4, 2023
1 parent f3f97bb commit c32a812
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/syn.cat
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ num x = ! if eq len x "S0" spack digit x cat cat cat cat cat cat cat `add mul "`
spack x = cat cat `"` x `"`
leq x y = in x y
show x = ! if leq len x digit "9" spack revdigit x cat cat cat cat `cat show "` let "SSSSSSSSSS" "S" sub x let "SSSSSSSSSS" "" x `" revdigit "` let "SSSSSSSSSS" "" x `"`
fib x = if eq x zero zero ! if leq x num "2" spack num "1" "add fib pred x fib pred pred x"
12 changes: 12 additions & 0 deletions examples/syn.meow
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,15 @@ show(x) {
};
!(if(leq(len(x), digit("9")), spack(revdigit(x)) , `cat show "` + rem + `" revdigit "` + la + `"`))
}

fib(x) {
if(
eq(x, zero()),
zero(),
!(if(
leq(x, num("2")),
spack(num("1")),
`add fib pred x fib pred pred x`
))
)
}

0 comments on commit c32a812

Please sign in to comment.