!while, !endwhile keywords are used to define loops.
loops.txt
@startuml
!procedure $fib($arg)
!$a = 0
!$b = 1
!$counter = 0
!$fib = 0
!while $counter < $arg
#DarkSalmon:for the iteration $counter;
#palegreen:a=$a, b=$b;
!$fib = $a + $b
!$a = $b
!$b = $fib
#palegreen:fib=$fib;
!$counter = $counter + 1
!endwhile
!endprocedure
start
$fib(5)
end
@enduml
Above snippet shows what is happening in each iteration of fibonacci number calculation.
No comments:
Post a Comment