• NEW ARTICLE: From infix notation to postfix notation

    From Marc Petremann@21:1/5 to All on Thu Oct 20 13:45:37 2022
    Handling complex arithmetic formulas can become a source of errors in FORTH. Here, we will define the way to handle large formulas in infix notation and compile them in postfix notation.

    https://esp32.arduino-forth.com/article/tools_infixToPostfix

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Paul Rubin@21:1/5 to Marc Petremann on Thu Oct 20 18:10:50 2022
    Marc Petremann <mpetremann93m@gmail.com> writes:
    Handling complex arithmetic formulas can become a source of errors in
    FORTH. Here, we will define the way to handle large formulas in infix notation and compile them in postfix notation.

    Does your Forth have local variables? That helps a lot. I think people
    who want infix aren't likely to use Forth in the first place.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From none) (albert@21:1/5 to no.email@nospam.invalid on Fri Oct 21 12:18:23 2022
    In article <87pmemf0bp.fsf@nightsong.com>,
    Paul Rubin <no.email@nospam.invalid> wrote:
    Marc Petremann <mpetremann93m@gmail.com> writes:
    Handling complex arithmetic formulas can become a source of errors in
    FORTH. Here, we will define the way to handle large formulas in infix
    notation and compile them in postfix notation.

    Does your Forth have local variables? That helps a lot. I think people
    who want infix aren't likely to use Forth in the first place.

    Prof Noble was right. There is great merit in being able to copy
    checking complex formulae from textbooks verbatim.
    Probably most notable in a practical technical environment.

    Groetjes
    --
    "in our communism country Viet Nam, people are forced to be
    alive and in the western country like US, people are free to
    die from Covid 19 lol" duc ha
    albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Marc Petremann@21:1/5 to All on Fri Oct 21 07:35:24 2022
    Le vendredi 21 octobre 2022 à 03:10:53 UTC+2, Paul Rubin a écrit :
    Does your Forth have local variables? That helps a lot. I think people
    who want infix aren't likely to use Forth in the first place.

    ESP32forth uses local variables.
    I didn't want to use them for my examples, because when decompiling, we no longer see the names of the variables.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From dxforth@21:1/5 to albert on Sat Oct 22 12:58:20 2022
    On 21/10/2022 9:18 pm, albert wrote:
    In article <87pmemf0bp.fsf@nightsong.com>,
    Paul Rubin <no.email@nospam.invalid> wrote:
    Marc Petremann <mpetremann93m@gmail.com> writes:
    Handling complex arithmetic formulas can become a source of errors in
    FORTH. Here, we will define the way to handle large formulas in infix
    notation and compile them in postfix notation.

    Does your Forth have local variables? That helps a lot. I think people
    who want infix aren't likely to use Forth in the first place.

    Prof Noble was right. There is great merit in being able to copy
    checking complex formulae from textbooks verbatim.
    Probably most notable in a practical technical environment.

    Paul is right. FTRAN is no path to Forth acceptance. Was FTRAN a neat application that caught a number of forthers' imagination? It would
    appear so. Still, the number of apps requiring users to plug in arbitrary textbook formula strikes me as extremely low to the point of 'who cares
    whether forth can do that'.

    BTW what is "practical technical environment"? We've had Wayne's "real practical imagination". Perhaps there needs to be a trading halt on
    the use of the word "practical" before it loses all meaning :)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Hans Bezemer@21:1/5 to none albert on Mon Oct 24 00:47:03 2022
    On Friday, October 21, 2022 at 12:18:26 PM UTC+2, none albert wrote:
    Prof Noble was right. There is great merit in being able to copy
    checking complex formulae from textbooks verbatim.
    Probably most notable in a practical technical environment.
    There certainly is. 4tH supports such expansion in its preprocessor, using
    the LET command.

    When I tried to convert the famous "batman" equation into 4tH, it most certainly was helpful, since they are *godawful*!

    What can I say - it worked ;-) https://sourceforge.net/p/forth-4th/code/HEAD/tree/trunk/4th.src/4pp/gbatman.4pp

    I wish I'd had such functionality when coding the 'teonw' program. All those formulas
    had to be handcoded. https://sourceforge.net/p/forth-4th/code/HEAD/tree/trunk/4th.src/4pp/teonw.4pp

    Hans Bezemer

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Marcel Hendrix@21:1/5 to the.bee...@gmail.com on Mon Oct 24 10:35:37 2022
    On Monday, October 24, 2022 at 9:47:04 AM UTC+2, the.bee...@gmail.com wrote:
    On Friday, October 21, 2022 at 12:18:26 PM UTC+2, none albert wrote:
    Prof Noble was right. There is great merit in being able to copy
    checking complex formulae from textbooks verbatim.
    Probably most notable in a practical technical environment.
    There certainly is. 4tH supports such expansion in its preprocessor, using the LET command.

    When I tried to convert the famous "batman" equation into 4tH, it most certainly was helpful, since they are *godawful*!

    What can I say - it worked ;-) https://sourceforge.net/p/forth-4th/code/HEAD/tree/trunk/4th.src/4pp/gbatman.4pp

    I wish I'd had such functionality when coding the 'teonw' program. All those formulas
    had to be handcoded. https://sourceforge.net/p/forth-4th/code/HEAD/tree/trunk/4th.src/4pp/teonw.4pp

    Hans Bezemer

    I need some motivation: what does 'batman' actually do?

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From dxforth@21:1/5 to Marcel Hendrix on Tue Oct 25 14:08:49 2022
    On 25/10/2022 4:35 am, Marcel Hendrix wrote:
    On Monday, October 24, 2022 at 9:47:04 AM UTC+2, the.bee...@gmail.com wrote:
    On Friday, October 21, 2022 at 12:18:26 PM UTC+2, none albert wrote:
    Prof Noble was right. There is great merit in being able to copy
    checking complex formulae from textbooks verbatim.
    Probably most notable in a practical technical environment.
    There certainly is. 4tH supports such expansion in its preprocessor, using >> the LET command.

    When I tried to convert the famous "batman" equation into 4tH, it most
    certainly was helpful, since they are *godawful*!

    What can I say - it worked ;-)
    https://sourceforge.net/p/forth-4th/code/HEAD/tree/trunk/4th.src/4pp/gbatman.4pp

    I wish I'd had such functionality when coding the 'teonw' program. All those formulas
    had to be handcoded.
    https://sourceforge.net/p/forth-4th/code/HEAD/tree/trunk/4th.src/4pp/teonw.4pp

    Hans Bezemer

    I need some motivation: what does 'batman' actually do?

    Given an entire f/p application could theoretically be written in infix, where to draw the line - if at all? That's a question for the forth scientific users.
    For me, f/p apps tend to be as rare as hens' teeth so the issue never arises.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Hans Bezemer@21:1/5 to Marcel Hendrix on Tue Oct 25 14:28:07 2022
    On Monday, October 24, 2022 at 7:35:39 PM UTC+2, Marcel Hendrix wrote:
    I need some motivation: what does 'batman' actually do?
    It's a set of equations that plot the "batman" logo. Google "batman equation" and a lot of links will pop up.

    Hans Bezemer

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Paul Rubin@21:1/5 to Hans Bezemer on Tue Oct 25 14:49:58 2022
    Hans Bezemer <the.beez.speaks@gmail.com> writes:
    It's a set of equations that plot the "batman" logo. Google "batman equation" and a lot of links will pop up.

    Heh cute. This one is informative: https://math.stackexchange.com/q/54506

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From dxforth@21:1/5 to Paul Rubin on Wed Oct 26 12:16:03 2022
    On 26/10/2022 8:49 am, Paul Rubin wrote:
    Hans Bezemer <the.beez.speaks@gmail.com> writes:
    It's a set of equations that plot the "batman" logo. Google "batman equation"
    and a lot of links will pop up.

    Heh cute. This one is informative: https://math.stackexchange.com/q/54506

    One for the mathematicians...

    \ This version translated to DX-Forth
    \
    \ FORTH-F.EXE - INCLUDE WEED BYE
    \
    \ -----------------------------------------------
    \ Originally programmed in XPL0 by ...
    \
    \ http://www.idcomm.com/personal/lorenblaney/
    \
    \ Weed.xpl 15-Jan-2009
    \ Plots the "Weed" function

    empty forth definitions decimal
    application

    1 fload XPLGRAPH \ XPL0 graphics

    100.e fconstant S \ size of plotted image (scale factor)
    32000.e fconstant N \ number of points plotted
    3.14159265e 2.e f* fconstant 2Pi
    0 value X \ graphic coordinates (pixels)
    0 value Y

    : Main ( -- )
    $12 SetVid \ set 640x480 graphics with 16 colors
    0.0e ( Angle) \ for A:= 0 to Pi2 do...
    begin
    fdup ( A) fsin 1.e f+
    fover ( A) 8.e f* fcos 0.9e f* 1.e f+ f*
    fover ( A) 24.e f* fcos 0.1e f* 1.e f+ f*
    fover ( A) 200.e f* fcos 0.05e f* 0.9e f+ f* ( Distance)
    fover ( A) fcos fover ( D) f* S f* f>s to X \ polar to rect
    fover ( A) fsin f* S f* f>s to Y
    320 X + 400 Y - 2 ( green) Point
    ( A) 2Pi N f/ f+ fdup 2Pi f< not
    until ( A) fdrop
    key drop \ wait for keystroke
    $03 SetVid \ restore normal text mode
    ;

    cr .( Save to disk? ) y/n
    [if] turnkey Main WEED [then]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Hans Bezemer@21:1/5 to dxforth on Thu Oct 27 10:13:41 2022
    On Wednesday, October 26, 2022 at 3:16:11 AM UTC+2, dxforth wrote:
    On 26/10/2022 8:49 am, Paul Rubin wrote:
    One for the mathematicians...

    .. and the 4tH version. This one fills it up as well. Nice code, easy to port:

    \ This version translated to DX-Forth

    \ FORTH-F.EXE - INCLUDE WEED BYE

    \ -----------------------------------------------
    \ Originally programmed in XPL0 by ...

    \ http://www.idcomm.com/personal/lorenblaney/

    \ Weed.xpl 15-Jan-2009
    \ Plots the "Weed" function

    [PRAGMA] usestackflood

    include lib/fp3.4th \ for floating point
    include lib/fsinfcos.4th \ for FSIN
    include lib/graphics.4th \ for graphics support
    include lib/gflood.4th \ for FLOOD
    include 4pp/lib/float.4pp \ since we're using the preprocessor..


    f% 100 fconstant S \ size of plotted image (scale factor) f% 32000 fconstant N \ number of points plotted
    pi fdup f+ fconstant 2Pi
    0 value X \ graphic coordinates (pixels)
    0 value Y

    : Main ( -- )
    640 pic_width ! 480 pic_height ! \ set canvas size
    color_image 255 whiteout black \ paint black on white
    ." WAIT! - it will get there.." cr \ set 640x480 graphics with 16 colors

    f% 0 ( Angle) \ for A:= 0 to Pi2 do...

    begin
    fdup ( A) fsin f% 1 f+
    fover ( A) f% 8 f* fcos f% 0.9e f* f% 1 f+ f*
    fover ( A) f% 24 f* fcos f% 0.1e f* f% 1 f+ f*
    fover ( A) f% 200 f* fcos f% 0.05e f* f% 0.9e f+ f* ( Distance)
    fover ( A) fcos fover ( D) f* S f* f>s to X \ polar to rect
    fover ( A) fsin f* S f* f>s to Y
    320 X + 400 Y - swap set_pixel
    ( A) 2Pi N f/ f+ fdup 2Pi f< 0=
    until ( A) fdrop
    ;

    Main
    green 200 320 flood
    s" weed.ppm" save_image \ save the image

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From dxforth@21:1/5 to Hans Bezemer on Fri Oct 28 08:03:54 2022
    On 28/10/2022 4:13 am, Hans Bezemer wrote:
    On Wednesday, October 26, 2022 at 3:16:11 AM UTC+2, dxforth wrote:

    One for the mathematicians...

    .. and the 4tH version. This one fills it up as well. Nice code, easy to port:

    BTW the original XPL0 code is now here:

    https://web.archive.org/web/20220403073604/http://www.xpl0.org/guess.html

    Don't know why author suggested it was 'for the mathematically inclined'. Perhaps they have an affinity for it :)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)