FOR IN {} suggestion for HP team - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: FOR IN {} suggestion for HP team (/thread-2472.html) |
FOR IN {} suggestion for HP team - Gilles - 11-22-2014 01:59 PM It would be fine to have this kind of syntax with the Prime like in Mapple : FOR n IN { } DO END For example : FOR n IN {"Bleu" "Blanc" "Rouge"} Do PRINT(n); END would result in Bleu Blanc Rouge This will allow things like FOR n IN { 1 7 3 9 10 11 } DO .. And why not { 3..10} to give easily {3 4 5 6 7 8 9 10} RE: FOR IN {} suggestion for HP team - lenborje - 12-01-2014 10:00 AM In programming languages that use a for-construct to do list processing, the list is often not modifiable during the loop. I usually need to add elements to the list during processing, and thus use the pattern below: LOCAL lst = { ... whatever .. }; WHILE SIZE(lst) DO LOCAL element=head(lst); lst:=tail(lst); ... END; RE: FOR IN {} suggestion for HP team - Tim Wessman - 12-01-2014 03:54 PM Why would anyone ever want a loop in a programming language that iterates over a fixed sized collection of some type of object? I can't imagine how that would be useful nor any language that has something similar... /s RE: FOR IN {} suggestion for HP team - Han - 12-01-2014 04:15 PM (12-01-2014 03:54 PM)Tim Wessman Wrote: Why would anyone ever want a loop in a programming language that iterates over a fixed sized collection of some type of object? I can't imagine how that would be useful nor any language that has something similar... I think the idea was not to actually loop over a fixed sized list, but to simply enable looping over lists so that one could do something like: Code:
where mylist is created dynamically. RE: FOR IN {} suggestion for HP team - ndzied1 - 12-01-2014 06:17 PM perhaps the /s means sarcasm off... RE: FOR IN {} suggestion for HP team - parisse - 12-01-2014 06:41 PM I agree with Han, iteration over a list is useful (it is the standard way to make loops in python by the way), and it is implemented in Xcas (with maple-like syntax). RE: FOR IN {} suggestion for HP team - Gilles - 12-01-2014 06:51 PM Python for example : Code:
Or Mapple : Code:
Or Ada, C, D, Delphi, Pascal, PHP,Perl , etc etc etc : http://en.wikipedia.org/wiki/Foreach_loop Of course the idea was not to be limited to fixed list... RE: FOR IN {} suggestion for HP team - Han - 12-01-2014 06:54 PM (12-01-2014 06:17 PM)ndzied1 Wrote: perhaps the /s means sarcasm off... Ha! It went completely over my head! <blush> |