2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -2,7 +2,7 @@ with Ada.Text_IO; use Ada.Text_IO;
with Ada.Numerics.Discrete_Random;
procedure Test_Loop_Break is
type Value_Type is range 1..20;
type Value_Type is range 0..19;
package Random_Values is new Ada.Numerics.Discrete_Random (Value_Type);
use Random_Values;
Dice : Generator;

View file

@ -0,0 +1,5 @@
10 LET a = INT (RND * 20)
20 PRINT a
30 IF a = 10 THEN STOP
40 PRINT INT (RND * 20)
50 GO TO 10

View file

@ -2,16 +2,16 @@
#include <time.h>
#include <stdio.h>
int main() {
int a, b;
#define LOWER 0
#define UPPER 19
int main() {
srand(time(NULL));
while (1) {
a = rand() % 20; /* not exactly uniformly distributed, but doesn't matter */
for (;;) {
unsigned a = LOWER + rand() / (RAND_MAX / (UPPER - LOWER + 1) + 1);
printf("%d\n", a);
if (a == 10) break;
b = rand() % 20; /* not exactly uniformly distributed, but doesn't matter */
printf("%d\n", b);
}
return 0;
}

View file

@ -0,0 +1,4 @@
loop
print a = Math.random() * 20 // 1
break if a == 10
print Math.random() * 20 // 1

View file

@ -1,7 +1,4 @@
(loop
(setq a (random 20))
(print a)
(if (= a 10)
(return))
(setq b (random 20))
(print b))
(loop for a = (random 20)
do (print a)
until (= a 10)
do (print (random 20)))

View file

@ -1,15 +1,13 @@
defmodule Loops do
def break do
:random.seed(:os.timestamp)
break(:random.uniform(20)-1)
def break, do: break(random)
defp break(10), do: IO.puts 10
defp break(r) do
IO.puts "#{r},\t#{random}"
break(random)
end
def break(10), do: IO.puts 10
def break(r) do
IO.write r
IO.puts ",\t#{:random.uniform(20)-1}"
break(:random.uniform(20)-1)
end
defp random, do: Enum.random(0..19)
end
Loops.break

View file

@ -0,0 +1,7 @@
loop(
a := Random value(0,20) floor
write(a)
if( a == 10, writeln ; break)
b := Random value(0,20) floor
writeln(" ",b)
)

View file

@ -1,34 +1,14 @@
18
10
16
10
8
0
13
3
2
14
15
17
14
7
10
8
0
2
0
2
5
16
3
16
6
7
19
0
16
9
7
11
17
10
console.log(
(function streamTillInitialTen() {
var nFirst = Math.floor(Math.random() * 20);
if (nFirst === 10) return [10];
return [
nFirst,
Math.floor(Math.random() * 20)
].concat(
streamTillInitialTen()
);
})().join('\n')
);

View file

@ -0,0 +1,11 @@
import java.util.Random
fun main(args: Array<String>) {
val rand = Random()
while (true) {
val a = rand.nextInt(20)
println(a)
if (a == 10) break
println(rand.nextInt(20))
}
}

View file

@ -1,9 +1,9 @@
import random
from random import randrange
while True:
a = random.randrange(20)
print a
a = randrange(20)
print(a)
if a == 10:
break
b = random.randrange(20)
print b
b = randrange(20)
print(b)

View file

@ -1,15 +1,14 @@
use rand::Rng;
// cargo-deps: rand
extern crate rand;
use rand::distributions::{Range, IndependentSample};
fn main() {
let mut rng = rand::thread_rng();
loop {
let num = rng.gen_range(0, 20);
println!("{}", num);
let num = Range::new(0, 19 + 1).ind_sample(&mut rand::thread_rng());
if num == 10 {
println!("{}", num);
break;
}
println!("{}", rng.gen_range(0, 20));
}
}