about summary refs log tree commit diff stats
path: root/new_lesson
blob: 3642b8233c22ca952693006ddd2ae4cd6f491aea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/sh
# Run this before running './mu edit' or './mu sandbox' to make sure you don't
# lose any work.
#
# You'll be editing code in lesson/recipes.mu, and any sandboxes you create
# will be in lesson/0, lesson/1, etc., from top to bottom.

set -e

mkdir lesson
cd lesson
git init
echo '**/.*.swp' > .gitignore
git add .
git commit -m 0
-01 17:30:14 -0700 committer Kartik K. Agaram <vc@akkartik.com> 2015-10-01 17:30:14 -0700 2232' href='/akkartik/mu/commit/064random.cc?h=hlt&id=166e3c0d407a967d25d793b6a9db56ffd7a03727'>166e3c0d ^
8cb4e365 ^




1c57bab6 ^

ec99eb7a ^
1c57bab6 ^
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
                                             
            
                                        
                                                
                                       
                   

        
                                                
                   
                                                                
                                                         
                     






                                             
                                                                                  



                                       




                                                

                                      
                     
         
:(before "End Primitive Recipe Declarations")
REAL_RANDOM,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "real-random", REAL_RANDOM);
:(before "End Primitive Recipe Checks")
case REAL_RANDOM: {
  break;
}
:(before "End Primitive Recipe Implementations")
case REAL_RANDOM: {
  // todo: limited range of numbers, might be imperfectly random
  // todo: thread state in extra ingredients and products
  products.resize(1);
  products.at(0).push_back(rand());
  break;
}

:(before "End Primitive Recipe Declarations")
MAKE_RANDOM_NONDETERMINISTIC,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "make-random-nondeterministic", MAKE_RANDOM_NONDETERMINISTIC);
:(before "End Primitive Recipe Checks")
case MAKE_RANDOM_NONDETERMINISTIC: {
  break;
}
:(before "End Primitive Recipe Implementations")
case MAKE_RANDOM_NONDETERMINISTIC: {
  srand(time(NULL));
  break;
}

// undo non-determinism in later tests
:(before "End Reset")
srand(0);