about summary refs log tree commit diff stats
path: root/999spaces.cc
Commit message (Expand)AuthorAgeFilesLines
* 3561Kartik K. Agaram2016-10-221-2/+2
* 2735 - define recipes using 'def'Kartik K. Agaram2016-03-081-3/+3
* 2708 - update map of transform orderingKartik K. Agaram2016-02-251-6/+10
* 2607 - resolve some edge cases in static dispatchKartik K. Agaram2015-11-291-0/+13
* 2504 - support to-text in 'stash'Kartik K. Agaram2015-11-281-0/+1
* 2502Kartik K. Agaram2015-11-281-3/+5
* 2501Kartik K. Agaram2015-11-281-5/+4
* 2500Kartik K. Agaram2015-11-281-2/+0
* 2499 - done reorganizing transformsKartik K. Agaram2015-11-281-4/+7
* 2498Kartik K. Agaram2015-11-281-4/+6
* 2497Kartik K. Agaram2015-11-281-1/+1
* 2496Kartik K. Agaram2015-11-281-4/+5
* 2495Kartik K. Agaram2015-11-281-2/+4
* 2494Kartik K. Agaram2015-11-281-17/+24
* 2493 - eliminate a couple of dependenciesKartik K. Agaram2015-11-281-3/+3
* 2492 - summarize current transformsKartik K. Agaram2015-11-281-0/+23
* 2313Kartik K. Agaram2015-10-291-4/+3
* 2261Kartik K. Agaram2015-10-061-3/+1
* 1842 - get layers building again after 2 weeksKartik K. Agaram2015-07-241-1/+1
* 1814 - save code in editorKartik K. Agaram2015-07-181-2/+4
* 1440Kartik K. Agaram2015-05-231-0/+1
* 1417 - draft zoom levels in tracesKartik K. Agaram2015-05-211-0/+11
* 1287Kartik K. Agaram2015-05-061-1/+2
* 1276 - make C++ version the defaultKartik K. Agaram2015-05-051-0/+21
<vc@akkartik.com> 2015-01-17 17:00:44 -0800 committer Kartik K. Agaram <vc@akkartik.com> 2015-01-17 17:00:44 -0800 578 - switch to non-polymorphic 'print' functions' href='/akkartik/mu/commit/generic.mu?h=hlt&id=4b62edd8a63cfdde37b0537c9be1e91062bb2892'>4b62edd8 ^
7d2c2d55 ^
f184c95e ^
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
                                                                             
                                                            
 

                                
                                                               
                                



                                                          

  
                 


                                                               
         


                                                


   
                
                                    
                                 
                                                
                           
  
; To demonstrate generic functions, we'll construct a factorial function with
; separate base and recursive clauses. Compare factorial.mu.

; factorial n = n*factorial(n-1)
(function factorial [
  (default-space:space-address <- new space:literal 30:literal)
  (n:integer <- input 0:literal)
  (x:integer <- subtract n:integer 1:literal)
  (subresult:integer <- factorial x:integer)
  (result:integer <- multiply subresult:integer n:integer)
  (reply result:integer)
])

; factorial 0 = 1
(function factorial [
  (default-space:space-address <- new space:literal 30:literal)
  (n:integer <- input 0:literal)
  { begin
    (zero?:boolean <- equal n:integer 0:literal)
    (break-unless zero?:boolean)
    (reply 1:literal)
  }
])

(function main [
  (1:integer <- factorial 5:literal)
  ($print (("result: " literal)))
  (print-integer nil:literal/terminal 1:integer)
  ($print (("\n" literal)))
])