MathGroup Archive 1995

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

Search the Archive

Re: Function?


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 ?