>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.
function age(d)
y=year(date())-year(d)
retu y-iif(gomo(d,y*12)<date(),0,1)
function age(d)
y=0
do whil d<date()
d=gomo(d,12)
y=y+1
endd
retu y-1
function age(d)
retu iif(gomo(d,12)>=date(),0,age(gomo(d,12))+1)
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)