Jump to content




Cf or Let Calculation to check values from list without Position maybe without recursion

let position recursion

  • Please log in to reply
2 replies to this topic

#1 OFFLINE   cat traveller  member

cat traveller
  • Members
  • 18 posts
  • FM Client:11 Advance
  • Platform:Mac OS X Snow Leopard
  • Skill Level:Intermediate
  • Time Online: 4h 17m 32s

Posted 16 February 2012 - 03:56 AM

Hello all,

still I did not fully understand how to implement recursion....

admittedly I am lost- and very much so:

There is a list of values = list
By script, I am looping through another list with keys.

Now I would like to check if the key is in the list.

First I was thinking to get the value with Position ( list ; key; 1; 1).
The problem is that in list, there might be 4651 and key might be 6, which would make Position true.
However 4651 is not 6.

Hence, I thought to loop through list by recursion and to check with the "=" but I dont know how to build this:

Let (
[
list = thelist;
k = thekey
counter = 1
c = valuecount (thelist)
];
Case ( counter > c ; "";
// this is my exit

GetValue ( list; 1) = k ; 1;
and here is am not getting the calc to recurse...


My second thought was to turn 6 into 0006 and then use Position. However the Length of the keys might change and
it seems not the right approach.

Who could help a dummy, please....

thanks

#2 OFFLINE   comment  consultant

comment
  • Members
  • 21,137 posts
  • Time Online: 187d 10h 40m 8s

Posted 16 February 2012 - 04:32 AM

Why not do it all at once, without recursion?

FilterValues ( keys ; list )

will return a list of keys that appear in list.

#3 OFFLINE   cat traveller  member

cat traveller
  • Members
  • 18 posts
  • FM Client:11 Advance
  • Platform:Mac OS X Snow Leopard
  • Skill Level:Intermediate
  • Time Online: 4h 17m 32s

Posted 16 February 2012 - 05:44 AM

Thanks a ton- this really helped- I was really lost on this one!


Back to Custom Functions



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users

FMForum Advertisers