I’ve been learning Elixir and some things, like the pipe operator |>
instantly clicked. And then I remembered Reverse Polish Notation, which I extensively used on HP48G while at ETH Zurich, and still use on my HP12C.
So, I asked ChatGPT:
I am very familiar with RPN operations on the HP48G graphing calculator. Why do I sense some similarities between RPN on the HP48G and how the Elixir pipe operator works?
ChatGPT’s response:
The Elixir pipe operator (|>) is similar to the Reverse Polish Notation (RPN) used on the HP48G graphing calculator in that both allow you to express computations as a series of operations that are performed on data as it flows through the system.
In RPN, data is pushed onto a stack and operations are performed by taking one or more items from the top of the stack, performing the operation, and pushing the result back onto the stack. For example, the expression 1 2 + in RPN would mean to take the two numbers 1 and 2 from the top of the stack, add them together, and push the result 3 back onto the stack.
The Elixir pipe operator works in a similar way, allowing you to express computations as a series of operations that are performed on data as it flows through the system.
Overall, the Elixir pipe operator and RPN share the idea of expressing computations as a series of operations that are performed on data as it flows through the system, rather than using a more traditional algebraic notation. This can make it easier to read and understand code, especially when working with complex computations.
No wonder!