The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

List processing problem HP 50g
Message #1 Posted by peacecalc on 28 Jan 2013, 3:50 p.m.

Hello RPL geeks,

I need your help!

I want to program a something which is feed by a list of two dim. vectors (the control points) and has bezier points (as vectors, too) as an output.

The problem for is the input or more precise to get the right three points.

The points are po, p1, p2, p3, p4, ...and so on.

Input: {po p1 p2 p3 p4 p5 p6}

I want a to get these lists:

{{po p1 p2} {p2 p3 p4} {p4 p5 p6}} or {po p1 p2 p2 p3 p4 p4 p5 p6}

This can be of course be programmed with direct accessing to the list, but maybe somebody know a method which uses the "parallel" list processing features of the HP 50g.

The three functions "DOLIST", "STREAM" and "SUBSET" don't solve my problem as far I know.

Sincerely peacecalc

Edited: 28 Jan 2013, 3:52 p.m.

      
Re: List processing problem HP 50g
Message #2 Posted by Werner on 28 Jan 2013, 4:19 p.m.,
in response to message #1 by peacecalc

The second list is easy

\<<
  1
  \<< NSUB 3 MOD NOT DUPN \>>
  DOSUBS
\>>
Will duplicate every third element and from that list
\<<
  3
  \<< 3 \->LIST \>>
  DOSUBS
\>>
Will produce the first list

Cheers, Werner

            
Re: List processing problem HP 50g
Message #3 Posted by Gilles Carpentier on 28 Jan 2013, 4:25 p.m.,
in response to message #2 by Werner

\<<
  1
  \<< NSUB 3 MOD NOT DUPN \>>
  DOSUBS
\>>

Excellent ;)

EDIT : oups.... in fact this don't work Gives : { po p1 p2 p2 p3 p4 p5 p5 p6 }

Edited: 28 Jan 2013, 4:41 p.m.

            
Re: List processing problem HP 50g
Message #4 Posted by Kiyoshi Akima on 28 Jan 2013, 4:35 p.m.,
in response to message #2 by Werner

This produces { { p0 p1 p2 } { p2 p3 p4 } { p5 p5 p6 } } which isn't quite what was requested.

Edited: Note that p5 is duplicated instead of p4.

Edited: 28 Jan 2013, 4:36 p.m.

      
Re: List processing problem HP 50g
Message #5 Posted by Gilles Carpentier on 28 Jan 2013, 4:21 p.m.,
in response to message #1 by peacecalc

Hi peacecalc !

Quote:
Input: {po p1 p2 p3 p4 p5 p6}

I want a to get these lists:

{{po p1 p2} {p2 p3 p4} {p4 p5 p6}}



 3  3 ->LIST NSUB 2 MOD NOT { DROP} IFT  DOSUBS

            
Re: List processing problem HP 50g
Message #6 Posted by peacecalc on 28 Jan 2013, 6:25 p.m.,
in response to message #5 by Gilles Carpentier

Hello Gilles Carpentier,

thank you for your fast solution. I've checked it and it works fine. For me it was a good lesson in RPL: your little piece of programming gem works in an unusual way. It produce every triple and deletes which are not wanted on the fly. Chapeau!

Normally someone who makes programs (that the way I'm think, too) is avoiding every needless calculation, but here it is the way, which overcomes the obstacle.

Again thank you very much!

Sincerely peacecalc

P.S.: Also to you Werner, thank you very much for your suggestions, even they aren't working, but they showed the possible way for a solution!

Edited: 28 Jan 2013, 6:28 p.m.

            
Re: List processing problem HP 50g
Message #7 Posted by Werner on 29 Jan 2013, 2:34 a.m.,
in response to message #5 by Gilles Carpentier

A similar trick can be used here:

\<<
 3 
 \<< 3 \->LIST NSUB 2 MOD NOT DROPN \>>
 DOSUBS
\>>

Cheers, Werner


[ Return to Index | Top of Index ]

Go back to the main exhibit hall