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 ==
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
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
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
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
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.Darticle_id=144562
Second, you propose
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];
//
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,
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't
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
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;
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) {
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://d.puremagic.com/issues/show_bug.cgi?id=4705
Denis Derman denis.s...@gmail.com changed:
What|Removed |Added
CC||denis.s...@gmail.com
http://d.puremagic.com/issues/show_bug.cgi?id=4705
--- Comment #3 from Denis Derman denis.s...@gmail.com 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
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
16 matches
Mail list logo