1. QBasic --> Euphoria (again)

For ABS,

function abs(atom x)
    if x >=3D 0 then return x
    elsif x < 0 then return -x
    end if
end function

--Alan
 =

new topic     » topic index » view message » categorize

2. Re: QBasic --> Euphoria (again)

On Tue, 1 Sep 1998, jiri babor wrote:

> Ralf, you wrote:
>
> function abs (object x)
>     return x < 0 * -2 + x
> end function
>
> Did you not really mean something like
>
> function abs(object x)
>     return -2*x*(x<0)+x   -- or perhaps (1-2*(x<0))*x
> end function

I'll have to get in on this one :)

function sgn(object x)
    return (x>0)-(x<0) -- or compare({x},{0})
end function

function abs(object x)
    return x*sgn(x)
end function

--
Carl R White
E-mail...: cyrek- at -bigfoot.com -- Remove the hyphens before mailing. Ta :)
Url......: http://www.bigfoot.com/~cyrek/
In my last few days on the net, I have room for a witty quote. Irony. :S

new topic     » goto parent     » topic index » view message » categorize

3. Re: QBasic --> Euphoria (again)

Good one, Carl! I especially like the sign function.


I have just compared (over several million cycles)

 function abs(object x)
     return -2*x*(x<0)+x
 end function


with your

function abs(object x)
    return x*((x>0)-(x<0))
end function


and yours is faster by about 4%! Congratulations! ;and -) jiri

new topic     » goto parent     » topic index » view message » categorize

4. Re: QBasic --> Euphoria (again)

> function abs(object x)
>     return x*((x>0)-(x<0))
> end function
>
> yours is faster by about 4%! Congratulations! ;and -) jiri

   I hope this is the kind of thing that makes it into the FAQ code
snippets section. :)

new topic     » goto parent     » topic index » view message » categorize

5. Re: QBasic --> Euphoria (again)

On Tue, 1 Sep 1998 00:00:10 -0400, Doug Cox
<cox.family at SK.SYMPATICO.CA> wrote:

>While doing some porting from QBasic to Euphoria,
>I came across some commands that I've been unable
>to stick into Euphoria. If anyone could offer a Euphoria
>equivalent to any of these, it would help a lot.

>WINDOW (resizes graphics display)

No equivalent.

>OUT (sends information to a port, I believe)

I believe you would have to write machine code for this.

>ABS (gives the ABSolute value of a number)

If this isn't one of the built-in math functions, you'll find
that compare(x,0) will work just as well.

>WAIT (??waits for information from ports??)

I believe you would have to write machine code for this.

--
Jeff Zeitlin
jeff.zeitlin at mail.execnet.com

new topic     » goto parent     » topic index » view message » categorize

6. Re: QBasic --> Euphoria (again)

How about:

function abs(atom x)
     if x < 0 then
        return -x
     end if
     return x
end function

Regards,

Greg Harris
HHS

-----Original Message-----
From: jiri babor <jbabor at PARADISE.NET.NZ>
To: EUPHORIA at LISTSERV.MUOHIO.EDU <EUPHORIA at LISTSERV.MUOHIO.EDU>
Date: Tuesday, September 01, 1998 9:36 AM
Subject: Re: QBasic --> Euphoria (again)


>Good one, Carl! I especially like the sign function.
>
>
>I have just compared (over several million cycles)
>
> function abs(object x)
>     return -2*x*(x<0)+x
> end function
>
>
>with your
>
>function abs(object x)
>    return x*((x>0)-(x<0))
>end function
>
>
>and yours is faster by about 4%! Congratulations! ;and -) jiri
>

new topic     » goto parent     » topic index » view message » categorize

7. Re: QBasic --> Euphoria (again)

>> WINDOW (resizes graphics display)
   I believe that this one would require a separate program-specific function,
   but as long as it's no problem, you could use graphics_mode...

>> OUT (sends information to a port, I believe)
   Ummm... it'd seem that ports.e would take care of that one.

>> WAIT (??waits for information from ports??)
   either ports.e, or for geniuses like myself (ahem...) you could use DOS
interrupts to call MODE and CTTY without using system().

                                                        James Begley

new topic     » goto parent     » topic index » view message » categorize

8. QBasic --> Euphoria (again)

Dear Euphorians,

While doing some porting from QBasic to Euphoria,
I came across some commands that I've been unable
to stick into Euphoria. If anyone could offer a Euphoria
equivalent to any of these, it would help a lot.

WINDOW (resizes graphics display)
OUT (sends information to a port, I believe)
ABS (gives the ABSolute value of a number)
WAIT (??waits for information from ports??)

Thanks!

Chris Cox
cox.family at sk.sympatico.ca

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu