Author Topic: Adventures with the HP 28S  (Read 5326 times)

0 Members and 1 Guest are viewing this topic.

Offline bb010g

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 428
  • Rating: +22/-1
  • I do stuff
    • View Profile
    • elsewhere on the net
Adventures with the HP 28S
« on: December 14, 2013, 02:29:04 pm »
A friend of the family gave me his HP 28S ADVANCED SCIENTIFIC CALCULATOR about a month ago, and I've been playing and hacking around with it. I figured that I'll document my findings and programs here, for posterity's, curiosity's, and the open source spirit's sake.

(Image coming soon)
Arch Linux user
Haskell newbie | Warming up to Lua | Being dragged into C++
Calculators: HP 50g, HP 35s, Casio Prizm, TI-Nspire CX CAS, HP 28s, HP Prime, Mathematica 9 (if that counts)
π: 3.14...; l: 108; i: 105; e: 101; l+i+e: 314
THE CAKE IS A LIE IS A PIE

Offline bb010g

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 428
  • Rating: +22/-1
  • I do stuff
    • View Profile
    • elsewhere on the net
Re: Adventures with the HP 28S
« Reply #1 on: December 14, 2013, 04:25:58 pm »
Functional Programming

I love functional programming (lambda calculus, Haskell, LISP) a lot. I also love RPN (RPL, Joy, Cat). They fit pretty well together. However, the 28S does not have compiler that is sufficiently smart enough to use list fusion (it doesn't compile AFAIK) so these can be slow. Use them for quick programs or proof-of-concepts, but not in large programs where speed is an issue.

MAP
MAP takes a list and a program and maps the program over the list.
Example: «{ 1 2 3 } « 1 + » MAP», when evaluated, returns {2 3 4}.
Code: [Select]
« OVER SIZE → l p s
  « l s FOR i
    l i GET p EVAL
    NEXT s →LIST
  »
»

MAPE (MAP Effectual)
MAPE takes a list and a program and applies the program to each argument, but doesn't care about outputs. Useful with PIXEL or putting things onto the stack.
Example: { (0,1) (0,2) (1,3) } « PIXEL » MAPE », when evaluated, plots the points (0,1), (0,2), and (1,3).
Code: [Select]
« OVER SIZE ROT ROT → l p
  « 1 SWAP FOR i
    l i GET p EVAL
    NEXT
  »
»

RANGE
RANGE takes a start, end, and a step, and returns a list from start to the closest number less than or equal to end, going by step.
Example: « 4 7 0.2 RANGE », when evaluated, returns { 4 4.2 4.4 4.6 4.8 5 5.2 5.4 5.6 5.8 6 6.2 6.4 6.6 6.8 7 }.
Code: [Select]
« → a b s
  « { } a b FOR i
    i +
    s STEP
  »
»

ZIPP (ZIP Program)
ZIPP takes two lists and a program and applies a program to each pair, stopping when one list runs out of items. (It's not called ZIP because that takes two lists returns a list of tuples (2 item lists here), but that doesn't have much use on a slow system like this and I'm lazy and could make it with « « { } + + » ZIPP ».)
Example: « { 1 2 3 } { 4 5 6 } « * » ZIPP », when evaluated, returns { 1 10 18 }.
Example: « { 1 2 3 } { 4 5 6 } « R→C » ZIPP », when evaluated, returns { (1,4) (2,5) (3,6) }.
Code: [Select]
« → xs ys p
  « { } 1 xs SIZE ys SIZE MIN FOR i
    xs i GET ys i GET p EVAL +
    NEXT
  »
»

ZIPPD (ZIP Program Duplicate)
Acts like ZIPP, except it takes one item as the first argument and acts as if the first list was infinite and composed only of it.
EXAMPLE: « 6 { « 7 * » « 2 - » « 2 ^ » } « EVAL » ZIPPD », when evaluated, returns { 42 4 36 }. You may ask, "Why not use MAP?" You cannot make a program that injects a local variable into a nested program (eg. « 42 « { « 7 / » } SWAP « → x « « x SWAP EVAL» MAP » » » EVAL », when evaluated would not return { 6 }, but 'x' as → only scopes one level.
Code: [Select]
« → x ys p
  « { } 1 ys SIZE FOR i
    x ys i GET p EVAL +
    NEXT
  »
»

Edit: Clarification and usage
« Last Edit: December 15, 2013, 11:40:21 pm by bb010g »
Arch Linux user
Haskell newbie | Warming up to Lua | Being dragged into C++
Calculators: HP 50g, HP 35s, Casio Prizm, TI-Nspire CX CAS, HP 28s, HP Prime, Mathematica 9 (if that counts)
π: 3.14...; l: 108; i: 105; e: 101; l+i+e: 314
THE CAKE IS A LIE IS A PIE

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Adventures with the HP 28S
« Reply #2 on: December 15, 2013, 08:58:00 pm »
To be honest, I have absolutely no clue what this stuff meant, so I can't comment. For example, by ZIP, do you mean like the compressed archives?

That said, I need to check out how much memory those older calcs have, because they seem interesting. Do they have a link port?

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: Adventures with the HP 28S
« Reply #3 on: December 15, 2013, 09:15:06 pm »
Many, if not all programming languages shares at least some similarities with C. I swear, this is not one of them.

RPL languages seems fun, though.

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Adventures with the HP 28S
« Reply #4 on: December 15, 2013, 09:27:07 pm »
Ah yes, I revived one of those for my uncle. We didn't have any N-sized batteries laying around, so I attached an AA battery holder to the back and ran wires to the inside of the battery compartment.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Adventures with the HP 28S
« Reply #5 on: December 17, 2013, 02:00:21 pm »
Do the original battery cost a lot of money/is easy to find?