That's the right algorithm, and the best you'll do in CFML.  However,
you've got a couple bits that are slightly off.  Here's the right
bits:

<cfset found = false />
<cfloop list="#listOne#" index="i">
  <cfif listFind(listTwo, i)>
    <cfset found = true />
    <cfbreak />
  </cfif>
</cfloop>

You want listFind instead of listContains, so you don't do substring
matching (e.g. "23" shouldn't match "1234").  And you can do a CFBREAK
once you find a match because searching the rest of the values is
irrelevant.

cheers,
barneyb

On Mon, Apr 27, 2009 at 7:25 PM, Seamus Campbell
<[email protected]> wrote:
>
> Hi
>
> I have 2 lists of numbers eg
> 16,20
> 16,23,78
>
> And I need a way to see if any one of the first list is in the second list.
> I can do it this way: (see below)
> SESSION.auth.user_role_id is first list and request.funds_carried_over_check 
> is second list.
> But this seems very clunky and I also may have more than one in a page.
>
> <cfset access_this = "No">
>    <cfloop list="#SESSION.auth.user_role_id#" index="i">
>    <cfif ListContains(request.funds_carried_over_check, i)>
>    <cfset access_this = "Yes">
>    </cfif>
>    </cfloop>
>      <cfif access_this IS "yes"> . . .  etc
>
> Is there any clever way of doing some sort of ListContains with 2 lists.
> Hope someone can help - tearing my hair out here (and there's not that much 
> left anyway)
>
> Seamus
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:322012
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to