about summary refs log tree commit diff stats
path: root/nqueens.mu
Commit message (Expand)AuthorAgeFilesLines
* 4134 - 'input' = 'ingredient'Kartik K. Agaram2017-12-031-4/+4
* 4008Kartik K. Agaram2017-09-251-3/+2
* 4007Kartik K. Agaram2017-09-251-2/+2
* 4006Kartik K. Agaram2017-09-241-5/+4
* 4005Kartik K. Agaram2017-09-241-0/+4
* 3681Kartik K. Agaram2016-11-221-3/+4
* 3656Kartik K. Agaram2016-11-101-6/+6
* 3483Kartik K. Agaram2016-10-081-10/+10
* 3389Kartik K. Agaram2016-09-171-5/+12
* 3380Kartik K. Agaram2016-09-171-16/+16
* 2996Kartik K. Agaram2016-05-211-1/+1
* 2986 - new example: the 8-queens problemKartik K. Agaram2016-05-201-0/+91
in&id=8923d6f658d09de800164b8fc6514475f49307b4'>^
72cf9948 ^
20d1c905 ^
72cf9948 ^
20d1c905 ^

72cf9948 ^
20d1c905 ^
72cf9948 ^






20d1c905 ^

1ead3562 ^
192d59d3 ^
d66e2783 ^
192d59d3 ^
20d1c905 ^

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
34
35
36
                                                      



                                                                           
                                                                   

                
                                   
             
             
                   

 
                         
                   
                    

 
                         
                               






                                   

 
          
                      
                                                                   
                              

 
# example program: constructing functions 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 basic demonstration of
# possibilities.

def factorial n:num -> result:num [
  local-scope
  load-inputs
  <factorial-cases>
]

after <factorial-cases> [
  # if n=0 return 1
  return-unless n, 1
]

after <factorial-cases> [
  # return n * factorial(n - 1)
  {
    break-unless n
    x:num <- subtract n, 1
    subresult:num <- factorial x
    result <- multiply subresult, n
    return result
  }
]

def main [
  1:num <- factorial 5
  # trailing space in next line is to help with syntax highlighting
  $print [result: ], 1:num, [ 
]
]