Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1995
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1995

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Function?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg2816] Re: [mg2810] Function?
  • From: Allan Hayes <hay at haystack.demon.co.uk>
  • Date: Wed, 20 Dec 1995 01:16:11 -0500

hans.steffani at e-technik.tu-chemnitz.de (Hans Steffani)
>Subject: [mg2810] Function?
wishes to simplify the following code

   aktiv[fx_]:=
      First[
         Position[
	    Table[norm[ w[[i,j]]-fx ] , {i,wsize},{j,wsize} ],
            Min[Table[norm[ w[[i,j]]-fx ] , {i,wsize},{j,wsize}]]
         ]
      ];


Here are two ways (the fourth entry in Position, after the level  
specification, {1}, stops the search when one example has been  
found). I leave the answer as a list in case it is empty.

   aktiv[fx_]:=
      With[{tab = Table[norm[ w[[i,j]]-fx ] , {i,wsize},{j,wsize} ]},
        Position[tab, Min[tab], {1}, 1]
      ];

    aktiv[fx_]:=
      Position[#, Min[#],{1}, 1]&[
      	Table[norm[ w[[i,j]]-fx ]{i,wsize},{j,wsize} ]
      ];

Allan Hayes
hay at haystack.demon.co.uk



  • Prev by Date: Programming
  • Next by Date: shell command
  • Previous by thread: Function?
  • Next by thread: Function parameters, using : and ?