Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Coding puzzle 2
Message
De
05/06/2002 10:10:34
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
05/06/2002 04:45:42
Mike Yearwood
Toronto, Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00664570
Message ID:
00664917
Vues:
24
Yes, you are right. I didn't read the message carefully enough. Here are the corrected versions, then.

>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>.
* Version 1
function age(b,d)
y=year(d)-year(b)
retu y-iif(gomo(b,y*12)<d,0,1)

* Version 2
function age(b,d)
y=0
do whil b<date()
	b=gomo(b,12)
	y=y+1
endd
retu y-1

* Version 3
function age(b,d)
retu iif(gomo(b,12)<d,age(gomo(b,12),d)+1,0)
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)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform