Is there no min() function in ebasic?

Michiel Sovijarvi-Spape mspape at cognitology.eu
Tue Jul 10 14:55:42 UTC 2012


Hi,
Wow, almost brings a C elegance to VB :) I benchmarked the functions, yours
is .3 microsecond shorter, though the difference is not statistically
significant. Good to know, For Science.
Best,
Michiel
 

-----Original Message-----
From: e-prime at googlegroups.com [mailto:e-prime at googlegroups.com] On Behalf
Of David McFarlane
Sent: 10 July 2012 17:09
To: e-prime at googlegroups.com; e-prime at googlegroups.com
Subject: Re: Is there no min() function in ebasic?

And here is a variant using the under-appreciated IIf() function (see that
topic in the E-Basic Help facility):

Function min( inx As Variant, iny As Variant ) As Variant
     min = IIf( (inx < iny), inx, iny )
End Function

-----
David McFarlane
E-Prime training
online:  http://psychology.msu.edu/Workshops_Courses/eprime.aspx
Twitter:  @EPrimeMaster (twitter.com/EPrimeMaster)


At 7/10/2012 09:01 AM Tuesday, Christopher Chatham wrote:
>Yes, rock on!
>
>I wasn't aware that we could implement functions of this kind. Thank 
>you very much.
>-Chris
>
>On Tue, Jul 10, 2012 at 8:41 AM, Michiel Sovijarvi-Spape 
><<mailto:mspape at cognitology.eu>mspape at cognitology.eu> wrote:
>Hi,
>
>Like you, I thought, that is pretty odd, but you seem correct 
>anyway. Nonetheless, there's an argument to be made against packing 
>all sorts of superfluous operations in a programming language (like 
>VBA), if you're not using them and are easily able to add them 
>yourself. So, just add to your user script:
>
>Function min(inx As Variant, iny As Variant) As Variant
>      If inx < iny Then min = inx Else min = iny
>End Function
>
>Now, writing
>TextDisplay1.Text = min(5,3)
>for example, will show "3". Rock on, no?
>Best,
>Mich
>
>
>From: <mailto:e-prime at googlegroups.com>e-prime at googlegroups.com 
>[mailto:e-prime at googlegroups.com] On Behalf Of Chris
>Sent: 10 July 2012 13:57
>To: <mailto:e-prime at googlegroups.com>e-prime at googlegroups.com
>Subject: Is there no min() function in ebasic?
>
>I realize I must be overlooking something, but I cannot find the 
>minimum function.  If I just want the smaller of two variables, do I 
>really have to construct an if statement for that?
>
>I realize that I can also put them in a summation object and use 
>summation.min; or I could put them in an array and sort it; but 
>surely the min() function must exist, right?

-- 
You received this message because you are subscribed to the Google Groups
"E-Prime" group.
To post to this group, send email to e-prime at googlegroups.com.
To unsubscribe from this group, send email to
e-prime+unsubscribe at googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/e-prime?hl=en.

-- 
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To post to this group, send email to e-prime at googlegroups.com.
To unsubscribe from this group, send email to e-prime+unsubscribe at googlegroups.com.
For more options, visit this group at http://groups.google.com/group/e-prime?hl=en.



More information about the Eprime mailing list