summary refs log tree commit diff stats
path: root/doc/pydoc/ranger.container.html
Commit message (Collapse)AuthorAgeFilesLines
* updated pydochut2010-04-201-5/+4
|
* updated pydochut2010-04-191-1/+2
|
* updated pydochut2010-03-121-4/+3
|
* incremented version number and updated pydoc html files v1.0.3hut2010-02-161-2/+2
|
* updated pydoc documentationhut2010-01-021-0/+1
|
* moved pydoc pages to doc/pydochut2009-12-251-0/+27
k.com> 2015-07-13 22:43:16 -0700 committer Kartik K. Agaram <vc@akkartik.com> 2015-07-13 22:50:49 -0700 1780 - now we always reclaim local scopes' href='/akkartik/mu/commit/factorial.mu?h=main&id=77d5b5d658830bd24724f945e0d6ddf6a06adc0e'>77d5b5d6 ^
4a48bedc ^
984a6321 ^





c1d92c9d ^
192d59d3 ^

32241605 ^
b96af395 ^
08b48a8d ^
b96af395 ^


192d59d3 ^
b96af395 ^
bafc7192 ^
b96af395 ^


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

                                             
          
             
                      
                          


 
                                   
             
             





                            
                             

                              
                                 
 
 


                         
                        
   
                         


            
# example program: compute the factorial of 5

def main [
  local-scope
  x:num <- factorial 5
  $print [result: ], x, [ 
]
]

def factorial n:num -> result:num [
  local-scope
  load-inputs
  {
    # if n=0 return 1
    zero?:bool <- equal n, 0
    break-unless zero?
    return 1
  }
  # return n * factorial(n-1)
  x:num <- subtract n, 1
  subresult:num <- factorial x
  result <- multiply subresult, n
]

# unit test
scenario factorial-test [
  run [
    1:num <- factorial 5
  ]
  memory-should-contain [
    1 <- 120
  ]
]