Post Reply 
HP 50g List function question
09-10-2017, 01:36 PM
Post: #8
RE: HP 50g List function question
(09-10-2017 07:21 AM)Gilles59 Wrote:  
(09-09-2017 10:47 PM)Andres1 Wrote:  {a, b, c} to {a, a+b, a+b+c}.

Hi, with Gopher List Library :

Code:
  « + » Scanl1

without external Library :

Code:
 1. 
 «
  CASE    
   NSUB 1. == THEN DUP END    @ special case first item : no +
   NSUB ENDSUB == THEN + END  @ special case last item : no DUP
   + DUP                      @ All other cases
  END
 »
DOSUBS

A nice, elegant version by Jeremy Hawdon, from Datafile Vol. 27 No.6:

Code:
\<< 0 SWAP 1.
   \<< OVER +
   \>> DOLIST NIP
\>>

Really, though, anyone doing this sort of programming needs to have GoferLists and ListExt.

John
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP 50g List function question - Andres1 - 09-09-2017, 10:47 PM
RE: HP 50g List function question - pier4r - 09-10-2017, 07:18 AM
RE: HP 50g List function question - pier4r - 09-10-2017, 09:40 AM
RE: HP 50g List function question - John Keith - 09-10-2017 01:36 PM
RE: HP 50g List function question - pier4r - 09-10-2017, 07:46 AM
RE: HP 50g List function question - DavidM - 09-10-2017, 03:28 PM
RE: HP 50g List function question - Juan14 - 09-10-2017, 07:41 PM



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