Post Reply 
list functions sugestion
09-22-2015, 08:04 AM (This post was last modified: 09-22-2015 08:05 AM by hpfx.)
Post: #9
RE: list functions sugestion
Hello,
(09-22-2015 05:46 AM)cyrille de brébisson Wrote:  Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
You probably work on hp prime calculators at hp (let's hope), wowww...

(09-22-2015 05:46 AM)cyrille de brébisson Wrote:  Hello,

It depends on what you are trying to achieve, but on Prime, you can do:
function(list) and function will apply to each element of the list.
This acts like a FOREACH.
But it is limited to math functions...

Cyrille
I didn't know that.
That's already interresting, but it was more to cover programming stuff.
Here is a (stupid) example:
Code:
L1:={4, 6, 9, 3};
FOREACH L1 AS itm;
   if(itm MOD 2 == 0) itm=itm-1;
END;
 // now L1 is { 3, 5, 9, 3 }

Of course, I know it can be achieved by
Code:

// These 2 lines replace suggested "FOREACH L1 AS itm"
FOR n FROM 1 TO SIZE(L1) DO
itm:=L1(n);

   // here goes block content

// these 2 lines replace suggested "END;"
L1(n):=itm;
END;

As well as all loops (FOR...) can be replaced by a simple WHILE cmd.
But we all find it conenient to use proper syntax for each loops.

If you at hp, you think it could be convenient to add this loop type, it would be nice, and I would like it. And it would make the hp-basic more modern, btw.

Of course, it's just an idea that can be extented to matrix, strings...

Thank you for your attention.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
list functions sugestion - hpfx - 09-20-2015, 07:55 PM
RE: list functions sugestion - komame - 09-20-2015, 08:41 PM
RE: list functions sugestion - hpfx - 09-20-2015, 08:49 PM
RE: list functions sugestion - komame - 09-20-2015, 08:53 PM
RE: list functions sugestion - hpfx - 09-20-2015, 08:59 PM
RE: list functions sugestion - douganc - 09-21-2015, 07:15 AM
RE: list functions sugestion - parisse - 09-21-2015, 09:15 AM
RE: list functions sugestion - hpfx - 09-22-2015 08:04 AM
RE: list functions sugestion - Tyann - 09-22-2015, 11:06 AM
RE: list functions sugestion - komame - 09-22-2015, 01:25 PM
RE: list functions sugestion - hpfx - 09-24-2015, 02:53 PM



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