[Issue 4705] Redesign of std.algorithm.max()/min() + mins()/maxs()

2014-03-18 Thread d-bugmail
https://d.puremagic.com/issues/show_bug.cgi?id=4705 --- Comment #18 from bearophile_h...@eml.cc 2014-03-18 16:59:19 PDT --- This Python program finds the number that has the largest minimum prime factor: def decompose(n): result = [] i = 2 while n >= i * i: while n % i == 0

[Issue 4705] Redesign of std.algorithm.max()/min() + mins()/maxs()

2013-09-03 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4705 --- Comment #17 from bearophile_h...@eml.cc 2013-09-03 09:45:18 PDT --- In dmd 2.064alpha you can't use minPos on a byKey range: import std.algorithm: minPos; void main() { int[int] aa = [1: 2]; int m1 = aa.byKey.minPos!((a, b) => a > b

[Issue 4705] Redesign of std.algorithm.max()/min() + mins()/maxs()

2013-04-14 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4705 --- Comment #16 from bearophile_h...@eml.cc 2013-04-14 14:23:35 PDT --- I still think mins()/maxs() are useful. But years after the original proposal an API change in max/min is now problematic (unless you want to introduce maximum/minimum funct

[Issue 4705] Redesign of std.algorithm.max()/min() + mins()/maxs()

2013-03-20 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4705 --- Comment #15 from bearophile_h...@eml.cc 2013-03-20 06:16:14 PDT --- In Haskell the reduce!min and reduce!max are named "minimum" and "maximum". -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are r

[Issue 4705] Redesign of std.algorithm.max()/min() + mins()/maxs()

2012-01-29 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4705 --- Comment #14 from bearophile_h...@eml.cc 2012-01-29 12:53:57 PST --- Another example of the usefulness of maxs/mins: http://rosettacode.org/wiki/Ordered_words#D > Define an ordered word as a word in which the letters of the word appear > in

[Issue 4705] Redesign of std.algorithm.max()/min() + mins()/maxs()

2011-10-12 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4705 --- Comment #13 from bearophile_h...@eml.cc 2011-10-12 15:55:39 PDT --- Part of A comment by Andrei Alexandrescu: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=144562 > Second, you propose > > mins(collec

[Issue 4705] Redesign of std.algorithm.max()/min() + mins()/maxs()

2011-09-14 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4705 --- Comment #12 from bearophile_h...@eml.cc 2011-09-14 15:51:52 PDT --- Another use case. Given this struct: struct Foo { double x; int[100] a; } This D code finds the struct with the smallest x and assigns it to good[index]: size_t

[Issue 4705] Redesign of std.algorithm.max()/min() + mins()/maxs()

2011-05-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4705 --- Comment #11 from bearophile_h...@eml.cc 2011-05-23 16:16:25 PDT --- (In reply to comment #10) > (Maybe I'd like an annotation to tell the compiler that "data" is an an Input > Range, unlike iota() that map is iterating on.) This bug doesn'

[Issue 4705] Redesign of std.algorithm.max()/min() + mins()/maxs()

2011-05-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4705 --- Comment #10 from bearophile_h...@eml.cc 2011-05-23 16:12:53 PDT --- The code that uses minPos() also leads to a possible bug (a real bug I have found in my code), shown here: import std.stdio, std.algorithm, std.math, std.range, std.random

[Issue 4705] Redesign of std.algorithm.max()/min() + mins()/maxs()

2011-05-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4705 --- Comment #9 from bearophile_h...@eml.cc 2011-05-23 05:12:44 PDT --- Another example, compared to using minPos(): import std.stdio, std.algorithm, std.array; void main() { string[] data = ["red", "hello", "yes", "no", "roger", "bud"];

[Issue 4705] Redesign of std.algorithm.max()/min() + mins()/maxs()

2011-03-25 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4705 --- Comment #8 from bearophile_h...@eml.cc 2011-03-25 10:35:06 PDT --- A max/min with a comparing function is present in the Haskel standard library too, named "maximumBy": import Data.List import Data.Ord longestWord words = maximumBy (compa

[Issue 4705] Redesign of std.algorithm.max()/min() + mins()/maxs()

2011-03-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4705 --- Comment #7 from bearophile_h...@eml.cc 2011-03-24 15:07:40 PDT --- The examples hopefully show how much useful are the new max/min. This is part of the "pivoting" part of a LU decomposition algorithm: T imax = mat[j][j]; int nrow = j; forea

[Issue 4705] Redesign of std.algorithm.max()/min() + mins()/maxs()

2011-02-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4705 --- Comment #6 from bearophile_h...@eml.cc 2011-02-13 05:51:55 PST --- Two more usage examples of the improved max. This program finds the longest common subsequence with a recursive algorithm: import std.stdio; T[] lcs(T)(T[] a, T[] b) {

[Issue 4705] Redesign of std.algorithm.max()/min() + mins()/maxs()

2011-01-01 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4705 --- Comment #5 from bearophile_h...@eml.cc 2011-01-01 06:33:02 PST --- Another example to show why a better max() is useful. The task is ot show how the number less than 1000 which has the longest hailstone sequence. For the hailstone see: http:

[Issue 4705] Redesign of std.algorithm.max()/min() + mins()/maxs()

2010-12-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4705 --- Comment #4 from bearophile_h...@eml.cc 2010-12-24 22:53:27 PST --- (In reply to comment #2) > Aren't they "niche domain" tools? The opposite is true. Functions and HOFs like max, min, sum, maxs, map, filter, reduce, and so on are basic bui

[Issue 4705] Redesign of std.algorithm.max()/min() + mins()/maxs()

2010-12-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4705 --- Comment #3 from Denis Derman 2010-12-24 11:17:33 PST --- Aside the posted comment, I rather support this proposal. Have you ever called an external func for min(a,b) or sum(a,b)? (lol ;-) So, according to me, what we need is a simple and

[Issue 4705] Redesign of std.algorithm.max()/min() + mins()/maxs()

2010-12-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4705 Denis Derman changed: What|Removed |Added CC||denis.s...@gmail.com --- Comment #2 fro

[Issue 4705] Redesign of std.algorithm.max()/min() + mins()/maxs()

2010-10-11 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4705 bearophile_h...@eml.cc changed: What|Removed |Added AssignedTo|nob...@puremagic.com|and...@metalanguage.com --- Co