Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- factorial(n:int) : int | effects [] {
- int acc = 1; {effect [write acc]} | {effect [write acc]}
- for ( int i = 1; {effects [write i]} | {effect [write i, write acc]}
- i <= n; {effects [read i, read n]} | {effect [write i, read i, write acc]}
- i++ {effects [read i, write i]} ){ | {effect [write i, read i, write acc]}
- acc *= i; {effects [read i, read acc, write acc]} | {effect [write i, read i, write acc]}
- } | {effect [read acc, write acc]} //i goes out of scope, so its effects are dropped
- | {effects [read acc]}
- return acc; | {effects []} //acc goes out of scope
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement