From: Peter Sisak on 31 Mar 2010 07:21 Hello, I see not how Nearest[] could be readily employed for this kind of analysis. Care to provide an example code snippet? Thank you Peter Sisak ---------------------------------------- > Date: Wed, 31 Mar 2010 05:27:55 -0500 > From: dmaxwarren(a)gmail.com > Subject: Re: 0/1 knapsack-like minimalization problem and file= system access > To: mathgroup(a)smc.vnet.net > > There are a number of functions in Mathematica 7 for doing just this > kind of analysis. Look up Nearest[]. > > Daniel > _________________________________________________________________
From: dr DanW on 1 Apr 2010 07:02 Ok, I admit that I was only looking at the first part of the problem, not the extension of the problem. I am also assuming that you have already used FileNames[] and FileByteCount[] to get the information in a list {size -> filename, ...} In[1]:= list = {3.4 -> "File1", 2.1 -> "File2", 6.5 -> "File3", 4.2 -> "File4"}; In[2]:= dist[a_, b_] := If[a <= b, b - a, 10*^10] In[3]:= Nearest[list, 3.3, DistanceFunction -> (dist[#2, #1] & )] Out[3]= {"File2"} The dist[] function is to take care of the less than condition. There may be more elegant ways of doing this. Daniel
|
Pages: 1 Prev: How to do numerical computations? Next: Speed Up of Calculations on Large Lists |