Hi Hilmar
All of your versions fail to meet the specification that the function accept 2 parameters, the birthdate and the "current" date ;). I deliberately went for the shortest version that met the speck. BTW, speck with a K is what I call anything that should have been a specification, but wasn't <g>.
>>Ok, that 'puzzle' from Hilmar was far too easy (took me 10 seconds, ok .. 30).
>>
>>Here's a nice contest. Who can write the shortest function (using native vfp functions/commands) that returns a person's age. Input is the birthday and the current date. The winner will get 3 points from me!
>
>Meneer Peter,
>
>I came up with three different versions of the age function.
>
>Version 1 is the fastest.
>
>Version 2 is slower to execute, but execution speed wasn't specified as a criterion.
>
>Version 3 is the shortest of them all, but won't work for people more than ca. 100 years old. It is only good for "showing off". However, I think it is correct for younger people.
>
>
>* Version 1
>function age(d)
>y=year(date())-year(d)
>retu y-iif(gomo(d,y*12)<date(),0,1)
>
>* Version 2
>function age(d)
>y=0
>do whil d<date()
> d=gomo(d,12)
> y=y+1
>endd
>retu y-1
>
>* Version 3
>function age(d)
>retu iif(gomo(d,12)>=date(),0,age(gomo(d,12))+1)
>