Thread Dynamisierung von Code - Grenzen der Machbarkeit? (13 answers)
Opened by ArthurDent at 2017-02-21 23:02

Muffi
 2017-02-22 08:18
#186151 #186151
User since
2012-07-18
1465 Artikel
BenutzerIn
[default_avatar]
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
my $n = 3;
my $k = 2;

sub iterate {
        my ($curr_n, @values) = @_;
        
        for my $curr_k (1..$k) {
                if ($curr_n == $n) {
                        say join(', ', (@values, $curr_k));
                }
                else {
                        iterate($curr_n +1, (@values, $curr_k));
                }
        }
}

iterate(1, ());

Last edited: 2017-02-22 08:30:11 +0100 (CET)
1 + 1 = 10

View full thread Dynamisierung von Code - Grenzen der Machbarkeit?