Post Reply 
prefix notation and () on newRPL project
01-13-2023, 04:15 PM (This post was last modified: 01-13-2023 11:22 PM by carey.)
Post: #11
RE: prefix notation and () on newRPL project
(01-22-2019 07:32 PM)Thomas Klemm Wrote:  
(01-22-2019 03:06 PM)The Shadow Wrote:  List comprehension alone would make my day.

What's wrong with SEQ?

Python

>>> [ x**2 + 1 for x in range(1, 11, 2) ]

[2, 10, 26, 50, 82]

Algebraic

'SQ(X)+1'
'X'
1 9 2
SEQ

{ 2 10 26 50 82 }

Or using RPL

« X SQ 1 + »
'X'
1 9 2
SEQ

{ 2 10 26 50 82 }


Kind regards
Thomas

Thomas, thanks for this clear comparison!

Just out of curiosity to see what this SEQ example would look like using the HP50g's not-often used algebraic mode (in contrast to the algebraic example in the quoted post that uses an algebraic expression in rpn mode), the following worked:

Code:

SEQ('SQ(X) + 1', 'X', 1, 9, 2)

{ 2 10 26 50 82 }

Two things surprised me: (i) the algebraic mode parameter list for SEQ was intuitive so it was easy to guess right the first time, and although I'm reluctant to admit it, (ii) the function call looks nicer (to me) in algebraic mode than in RPL or Python.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: prefix notation and () on newRPL project - carey - 01-13-2023 04:15 PM



User(s) browsing this thread: 1 Guest(s)