Post Reply 
Simple challenge in RPL, Extract the odd elements from a list
08-16-2017, 07:45 PM (This post was last modified: 08-16-2017 09:41 PM by pier4r.)
Post: #9
RE: Simple challenge in RPL, Extract the odd elements from a list
(08-16-2017 06:27 PM)DavidM Wrote:  If I was to use the ListExt library AND I knew that number of objects in the list was even, I would use this to extract the odd ones:
Code:
2 LDST HEAD
Changing HEAD to TAIL would result in the even-numbered elements. Or for a more "general purpose" approach, you could get every "nth" element (provided the list size is an even multiple of n) by placing n on the stack and executing the following:
Code:
LDST LRLL HEAD

Grammar question from non-native side: why did you use "if I was to use" instead of "if I had to use" ?

Anyway thanks for the info! I nevertheless drop a little objection reusing what someone said in another topic (maybe an old topic that I read while reading the general forum).

It is nice to know relatively short codes to define functionality over an existing library, but wouldn't be it more reasonable to have those - the quite generic ones - included in the library instead of having everyone build a library extension by himself? Especially if the author himself is so neat to offer the solution!

To me it seems like:
We have the set of functions A (from the userRPL builtin library), we can solve a lot with those but not that fast sometimes, so someone extends them with a library (or libraries) offering the set of functions B (see ListExt or Goferlist). Then there are still generic functions left out A and B that are discussed but not implemented in B, so one has to combine the functions in A and B to have his own library C of further generic functions.

Of course the above is possible and it is fun, but personally I'd like to see the additional functions in B.

Sure, if one does not find the functions of C in A or B, it is better than nothing to have them in one's own written library.

Said this, to emphasize that the objection was little: :hug:

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Simple challenge in RPL - compsystems - 08-16-2017, 12:54 PM
RE: Simple challenge in RPL, Extract the odd elements from a list - pier4r - 08-16-2017 07:45 PM



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