about summary refs log tree commit diff stats
path: root/cpp/.traces/get_indirect
Commit message (Expand)AuthorAgeFilesLines
* 1276 - make C++ version the defaultKartik K. Agaram2015-05-051-42/+0
* 1247Kartik K. Agaram2015-05-031-1/+1
* 1246Kartik K. Agaram2015-05-031-4/+4
* 1225Kartik K. Agaram2015-04-291-0/+4
* 1223 - more stable traces for parse scenariosKartik K. Agaram2015-04-291-4/+4
* 1213Kartik K. Agaram2015-04-281-1/+1
* 1194Kartik K. Agaram2015-04-241-0/+1
* 1184 - finally, concurrencyKartik K. Agaram2015-04-241-0/+1
* 1075Kartik K. Agaram2015-04-171-1/+1
* 1013Kartik K. Agaram2015-04-031-1/+1
* 997Kartik K. Agaram2015-03-301-9/+9
* 983 - arc 'integer-array' => c++ 'array:integer'Kartik K. Agaram2015-03-261-1/+1
* 968Kartik K. Agaram2015-03-241-4/+4
* 952Kartik K. Agaram2015-03-181-1/+0
* 949 - paving the way for jumps to labelsKartik K. Agaram2015-03-171-8/+9
* 941 - c++: basic break/loop conversionKartik K. Agaram2015-03-161-0/+5
* 940 - c++: some changes to instruction modelKartik K. Agaram2015-03-161-9/+9
* 832 - call-stack for C++ versionKartik K. Agaram2015-02-251-4/+4
* 819Kartik K. Agaram2015-02-221-2/+4
* 817Kartik K. Agaram2015-02-221-0/+29
ref='#n13'>13 14 15 16 17 18 19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





                                                                           


                  
             
                             







                   

                             
         



                               



                                        


             
                         
                                

 
# example program: constructing recipes out of order
#
# We construct a factorial function with separate base and recursive cases.
# Compare factorial.mu.
#
# This isn't a very tasteful example, just a simple demonstration of
# possibilities.

recipe factorial [
  local-scope
  n:number <- next-ingredient
  {
    +base-case
  }
  +recursive-case
]

after +base-case [
  # if n=0 return 1
  zero?:boolean <- equal n, 0
  break-unless zero?
  reply 1
]

after +recursive-case [
  # return n * factorial(n - 1)
  x:number <- subtract n, 1
  subresult:number <- factorial x
  result:number <- multiply subresult, n
  reply result
]

recipe main [
  1:number <- factorial 5
  $print [result: ], 1:number, [
]
]