Using Fold in Select
- To: mathgroup at smc.vnet.net
- Subject: [mg9035] Using Fold in Select
- From: Ramin Sina <sina at glue.umd.edu>
- Date: Wed, 8 Oct 1997 00:05:32 -0400
- Organization: University of Maryland, College Park
- Sender: owner-wri-mathgroup at wolfram.com
Hi all,
I am trying to write a fuction that does the following:
f[n_]:=Select[thedata,(
#[[1]]<fitmax[1,g[n]] &&
#[[2]]<fitmax[2,g[n]] &&
................... &&
#[[n]]<fitmax[n,g[n]]
) &]
thedata is a 100 by 1000 matrix. I tried to use a Fold of the And
functions:
f[n_]:=Select[thedata,
(Flatten[Fold[And,1,temp[n]]])
& ]
where temp[n] is defined by
For[i=nmin,i<=nmax,i++,
temp[i]={};
For[j=1,j<=i,j++,
AppendTo[temp[i],
#[[j]]<fitmax[j,g[i]]
]
]
]
But this obviously won't work because #[[j]] is not defined outside
"Select".
I also tried to use x[j] instead and the at the end do \.x[j]->#[[j]].
But
that won't work either. Any advice on to write this function in a
correct
and compact form would be deeply appreciated.
Ramin Sina
--
--------------------------------------------------------
Ramin Sina sina at glue.umd.edu rsina at concentric.net
Institute for Physical Science and Technology
University of Maryland College Park Maryland 20742
Voice (301) 405 4852 Fax (301) 314 9363