Postfix for Scheme+

Hi,

i added some postfix notation support for Scheme+.
There is not a lot of languages and systems supporting postfix syntax: RPN (Reverse Polish Notation) Hewlett Packard calculators (HP-65, HP-15C,HP-41C,HP-34C,....)
Also Forth language and more recently Rhombus.

Here are some examples:

#lang reader SRFI-105
(require Scheme+)

; factorial
{12 !} ; postfix
479001600

(! 5) ; normal prefix
120

{1 2 3 4 +}
10

{1 (4 5 *) 3 +}
24

; A mix of postfix,infix and prefix:
{2 (3 (9 - 5) *) (- 8 3) +}
19

(declare-postfix-operator *) ; when there is some ambiguity
{x := 7}
{1 (x 5 *) 3 +}
39

(define (C n k)
    {(n !) / ((k !) · ((n - k)!))})


(require flomat)
(define ᵀ transpose) ; transpose of a Matrix
(declare-postfix-operator ᵀ)
{A := (matrix #(#(1 2 3) #(4 5 6)))}

{A ᵀ}
(flomat: ((1.0 4.0) (2.0 5.0) (3.0 6.0)))

{(A ᵀ)ᵀ}
(flomat: ((1.0 2.0 3.0) (4.0 5.0 6.0)))

Bonne journée.

3 Likes

Hi,

just a few words about a technic called "Bootstrapping" that i now use internally for developping Scheme+ next features.

"Bootstrapping" allow a language or compiler to be written in the language it is currently defining. Whooaa this looks strange: how can the language be defined in the language if you are currently writing/upgrading with new feature.

You just need a previous version of the language and with a restriction, do not use in your code features you are currently coding of course.

I learnt Bootstrapping when i was a student in compilation classes but i did not think at this time i would never use it!

You can find more information in the wikipedia page:

for the fun , i discovered on facebook today some video of a good army comrade,now blacksmith, about social networks , i can not resist posting them here :smiley: , but this is french language

:rofl:

:rofl:

Bonne journée

Damien