Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Coding puzzle 2
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00664570
Message ID:
00664798
Vues:
15
>>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!
>
>Here's mine! I wrote it some years ago.
>
lpar B,D
>A=year(D)-year(B)
>RETU iif(gomo(B,A*12)>D,A-1,A)
>

If you want, you can even remove the params line if you declare the function this way:
FUNCTION age(b,d)
That way you get this:
A=year(D)-year(B)
RETU iif(gomo(B,A*12)>D,A-1,A)
48 chars only! :-)
If we exchange an apple, we both get an apple.
But if we exchange an idea, we both get 2 ideas, cool...


Gérald Santerre
Independant programmer - internet or intranet stuff - always looking for contracts big or small :)
http://www.siteintranet.qc.ca
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform