AvD Posted September 3, 2008 Posted September 3, 2008 Het café is wel niet de ideale plaats, maar voor alle posters die namen van andere posters hier zien als vrij anonieme mensen: we mogen blij zijn dat we hier iemand hebben als Jeroen Aerts. Lees anders maar eens na wat hij gepost heeft op filemaker.webcrossing in verband met recursieve functies. Dank, Jeroen! Quote
Mark Posted September 3, 2008 Posted September 3, 2008 Dit lijkt mij een interessant artikel, maar heb je misschien ook een linkje? Ik heb me rot gezocht, maar kan het niet vinden... Quote
AvD Posted September 3, 2008 Author Posted September 3, 2008 Het gaat over de thread "Recursion Help". Misschien dat Jeroen zelf zijn tekst wil citeren (samen met de voorafgaande vragen). Als hij het goed vindt, wil ik de tekst hier ook wel neerzetten. Quote
Jeroen Aarts Posted September 5, 2008 Posted September 5, 2008 Wel jongens, zoveel eer verdien ik echt niet hoor. Er zijn op dit forum posters die veel meer onbezoldigde tijd en energie steken om clarify - volgens mij - wereldwijd tot een van de meest actieve en sympathiekste 'user groups' te maken. De link zelf posten gaat niet, want het is een tread op FileMaker Technet, en niet ale clarifyers zijn lid van Technet - helaas. Voor de geïnteresseerden, ik reageerde, in mijn nimmer aflatende strijd tegen onrecht en misverstanden omtrent recursie, op een bericht waarop een goedbedoeld maar nogal gebrekkig antwoord werd geformuleerd op een vraag over recursieve functies. Als iemand mijn gebazel nog kan volgen, hier komt ie dan, dit is de oorspronkelijke vraag: I can't seem to figure out recursion. I have a field that has up 30+ entries comma demlimited and I want to be able to display 1-10, 11 -20 in return delim lists This is how far i have gotten Let ( Txt = Substitute ( Text ; ", " ; "�" ); ; If ( Start < End ; PackParse ( Txt ; Start + 1 ; End ); Txt )) It just returns the complete list. Thanks -- John Morina Pueblo Systems, Inc. a bit more info... the custom function is PackParse ( Text ; Start ; End ) I am putting the comma delim field with 20 entried and Start = 1 end = 10 -- John Morina Pueblo Systems, Inc. Hier is het antwoord: Hi, John. It doesn't work because the result to be processed when Start < End doesn't do anything except march through iterations until Start = End, at which point it returns Txt. The following would work, although you should just use MiddleValues as Ibrahim suggested: Let ( Txt = Substitute ( Text ; "," ; "¶" ) ; If ( Start ≤ End ; LeftValues ( Txt ; 1 ) & PackParse ( RightValues ( Txt ; ValueCount ( Txt ) - 1 ) ; Start + 1 ; End ) ) ) Regards, ... En hier is dan de post: I may be wrong, but I think that neither the explanation nor the example are correct. The reason why your recursion does not work is simply because Start < End always evaluates to true (as long as Start is less than End), and then your function simply returns Txt without any recursion. Robs example works as long as Start is 1, and doesn't work at all when Start is anything else than 1. The recursive function - which is far too complicated compared to MiddleValues() - would look like: PackParse(Text; Start; End): Let ([ Txt = Substitute ( Text ; "," ; "¶" ) ; Txt = RightValues(Txt ; (ValueCount(Txt) - Start) + 1) ; Start = 1 ; End = End - Start + 1 ] ; If ( Start < End ; LeftValues ( Txt ; 1 ) & PackParse ( RightValues ( Txt ; ValueCount ( Txt ) - 1 ) ; 1 ; End - 1 ) ) ) Just to say that this is a case where you would not want to write a recursive function - Jeroen Quote
Jeroen Aarts Posted September 5, 2008 Posted September 5, 2008 Mijn voorbeeld bekijkend, merk ik uiteraard dat er 2 overbodige lijnen in staan. Zoek de 2 verschillen: PackParse(Text; Start; End): Let ([ Txt = Substitute ( Text ; "," ; "¶" ) ; Txt = RightValues(Txt ; (ValueCount(Txt) - Start) + 1) ] ; If ( End > 1 ; LeftValues ( Txt ; 1 ) & PackParse ( RightValues ( Txt ; ValueCount ( Txt ) - 1 ) ; 1 ; End - 1 ) ) ) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.