Is there a more efficient way to look up a list?

Bruce Perryman <[email protected]> Tue, 16 May 2006 08:27:22 -0700 (PDT)
Newsgroups gmane.comp.text.fmpp
Message-ID <[email protected]>
--0-1545857472-1147793242=:26612
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

Hello. I hope that I explain this clearly enough.

Let's say I have the code 'BBB' stored in 'myCode' and the following list=
:

options=3D
[code:AAA,description:A1,text:A2,
 code:BBB,description:B1,text:B2,
 code:CCC,description:C1,text:C2,
 code:DDD,description:D1,text:D2]

I need to display the description of the code value that I have. What I c=
urrently do is the following:

                <#list options as x>=20
                 <#if (x.code?trim=3D=3Dmycode)> =20
                    ${x.description?trim}
                 </#if>
                </#list>      =20

It seems to work. But is there a more efficient way to do this?

Thanks.                     =20


	=09
---------------------------------
Love cheap thrills? Enjoy PC-to-Phone  calls to 30+ countries for just 2=A2=
/min with Yahoo! Messenger with Voice.
--0-1545857472-1147793242=:26612
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

Hello. I hope that I explain this clearly enough.<br><br>Let's say I have=
 the code 'BBB' stored in 'myCode' and the following list:<br><br>options=
=3D<br>[code:AAA,description:A1,text:A2,<br>&nbsp;code:BBB,description:B1=
,text:B2,<br>&nbsp;code:CCC,description:C1,text:C2,<br>&nbsp;code:DDD,des=
cription:D1,text:D2]<br><br>I need to display the description of the code=
 value that I have. What I currently do is the following:<br><br>&nbsp;&n=
bsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;#=
list options as x&gt; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nb=
sp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &lt;#if (x.code?trim=3D=3Dmycode)&gt;&=
nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ${x.description?trim}<br>&nbsp;&nbsp=
;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &lt;/#i=
f&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&=
nbsp;&nbsp;
 &lt;/#list&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br><br>It seems to w=
ork. But is there a more efficient way to do this?<br><br>Thanks. &nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  <br><br><p>
		<hr size=3D1>Love cheap thrills? Enjoy PC-to-Phone <a href=3D"http://us=
.rd.yahoo.com/mail_us/taglines/postman9/*http://us.rd.yahoo.com/evt=3D396=
66/*http://messenger.yahoo.com/"> calls to 30+ countries</a> for just 2=A2=
/min with Yahoo! Messenger with Voice.
--0-1545857472-1147793242=:26612--


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642