[Issue 4591] Concat of std.typecons.Tuples
https://issues.dlang.org/show_bug.cgi?id=4591 --- Comment #4 from github-bugzi...@puremagic.com --- Commit pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/cddd0df51a50e2c370162daa7ed7fca0dad4b979 Fix Issue 4591, 14637 - Array operations should work on tuples --
[Issue 4591] Concat of std.typecons.Tuples
https://issues.dlang.org/show_bug.cgi?id=4591 github-bugzi...@puremagic.com changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --
[Issue 4591] Concat of std.typecons.Tuples
https://issues.dlang.org/show_bug.cgi?id=4591 Seb changed: What|Removed |Added Keywords||pull CC||greensunn...@gmail.com --- Comment #3 from Seb --- https://github.com/dlang/phobos/pull/6386 --
[Issue 4591] Concat of std.typecons.Tuples
https://issues.dlang.org/show_bug.cgi?id=4591 Andrei Alexandrescu changed: What|Removed |Added Keywords||bootcamp --
[Issue 4591] Concat of std.typecons.Tuples
http://d.puremagic.com/issues/show_bug.cgi?id=4591 bearophile_h...@eml.cc changed: What|Removed |Added AssignedTo|and...@erdani.com |nob...@puremagic.com --- Comment #2 from bearophile_h...@eml.cc 2013-05-14 09:49:37 PDT --- I suggest to add the support for Tuple concatenation and join: In Python 2.6: >>> t1 = (1, 2) >>> t1 + t1 (1, 2, 1, 2) >>> t1 + (3,) (1, 2, 3) Proposed D syntax: void main() { import std.typecons; auto t1 = tuple(1, 2); auto t2 = t1 ~ t1; auto t3a = t1 ~ 3; auto t3b = t1 ~ tuple(3); } An use case, this computes the frequency of the first digit (Benford's Law): import std.stdio, std.range, std.math, std.conv, std.bigint, std.algorithm; auto benford(R)(R data) { auto heads = data.filter!q{a != 0}.map!q{ a.text[0] - '1' }.array; immutable double k = heads.length; return iota(1, 10) .zip(heads.sort().group.map!(p => p[1] / k)) .map!q{ [a[]] ~ log10(1.0 + 1.0 / a[0]) }; } void main() { auto fibs = recurrence!q{a[n - 1] + a[n - 2]}(1.BigInt, 1.BigInt); writefln("%9s %9s %9s", "Actual", "Expected", "Deviation"); foreach (p; fibs.take(1000).benford) writefln("%1.0f: %5.2f%% | %5.2f%% | %5.4f%%", p[0], p[1] * 100, p[2] * 100, abs(p[2] - p[1]) * 100); } Currently the benford() function returns a range of double[]: .map!q{ [a[]] ~ log10(1.0 + 1.0 / a[0]) }; If I want to return a range of 3-tuples: .map!q{ tuple(a[], log10(1.0 + 1.0 / a[0])) }; With the proposed syntax the code becomes: .map!q{ a ~ log10(1.0 + 1.0 / a[0]) }; Or: .map!q{ a ~ tuple(log10(1.0 + 1.0 / a[0])) }; -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4591] Concat of std.typecons.Tuples
http://d.puremagic.com/issues/show_bug.cgi?id=4591 --- Comment #1 from bearophile_h...@eml.cc 2011-07-25 05:30:07 PDT --- Slicing too is sometimes useful: import std.typecons; void main() { auto t1 = tuple(10, 20, 30, 40, 50); auto t2 = tuple(100, 200, 300); auto t3 = t1[0 .. 2]; // tuple slicing auto t4 = t1 ~ t2;// tuple concat } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4591] Concat of std.typecons.Tuples
http://d.puremagic.com/issues/show_bug.cgi?id=4591 Andrei Alexandrescu changed: What|Removed |Added Status|NEW |ASSIGNED CC||and...@metalanguage.com AssignedTo|nob...@puremagic.com|and...@metalanguage.com -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---