[racket-dev] Feature request- combined argmin and argmax in a single function

2012-06-27 Thread Harry Spier
It might be useful to add to the language a combined function such as
(argminmax proc lst) that returned both the minimum and maximum values
of applying proc to lst.  So that for very large lists (or for very
large numbers of lists where you need to know the min and max values
in the lists)  instead of having to traverse the lists twice (once
with argmin and once with argmax) you'd now only have to trarverse the
list once with argminmax.

Thanks,
Harry Spier
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] Feature request- combined argmin and argmax in a single function

2012-06-27 Thread Doug Williams
The science collection already has such a function (minimum-maximum
a-sequence) that works for any sequence - e.g., lists or vectors. For
example:

#lang racket

(require (planet williams/science/science))

(minimum-maximum
 (for/list ((i (in-range 10)))
   (random-unit-gaussian)))

(minimum-maximum
 (for/vector #:length 10
 ((i (in-range 10)))
   (random-unit-gaussian)))


Doug


On Wed, Jun 27, 2012 at 1:10 PM, Harry Spier vasishtha.sp...@gmail.com wrote:
 It might be useful to add to the language a combined function such as
 (argminmax proc lst) that returned both the minimum and maximum values
 of applying proc to lst.  So that for very large lists (or for very
 large numbers of lists where you need to know the min and max values
 in the lists)  instead of having to traverse the lists twice (once
 with argmin and once with argmax) you'd now only have to trarverse the
 list once with argminmax.

 Thanks,
 Harry Spier
 _
  Racket Developers list:
  http://lists.racket-lang.org/dev

_
  Racket Developers list:
  http://lists.racket-lang.org/dev