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.

2 Likes