Permutations: Difference between revisions
Content deleted Content added
Added missing in lazy D version |
Better lazy D entry |
||
Line 855:
<lang d>import std.algorithm, std.exception;
struct Permutations(bool doCopy=true, T) {
private immutable size_t num;
private T[] items;
Line 871:
return result;
}
this.num = items.length;
Line 878 ⟶ 877:
}
@property T[] front() /*const*/ pure /*nothrow*/ {
return items.dup; // not nothrow
else
}
Line 908 ⟶ 910:
}
Permutations!(doCopy,T) permutations(
(/*in*/ T[] items)
▲ return Permutations!T(items);
pure nothrow {
return Permutations!(doCopy, T)(items);
} unittest {
import std.bigint;
Line 919 ⟶ 923:
void main() {
import std.stdio;
foreach (p; permutations!false([1, 2, 3]))
writeln(p);
}
|