Post Reply 
newbie question: how to take element from an array on command line
12-27-2017, 05:20 PM
Post: #1
newbie question: how to take element from an array on command line
say `iquorem(63, 23)` returns [2, 17], how do I get 2, or 17 out of that array[/quote]
Find all posts by this user
Quote this message in a reply
12-27-2017, 06:10 PM
Post: #2
RE: newbie question: how to take element from an array on command line
Perhaps with 'iquorem(63,23)[1]' or [2]
Arno
Find all posts by this user
Quote this message in a reply
12-27-2017, 06:38 PM
Post: #3
RE: newbie question: how to take element from an array on command line
(12-27-2017 06:10 PM)Arno K Wrote:  Perhaps with 'iquorem(63,23)[1]' or [2]
Arno

Using [1] (or [2]) is ok in CAS, however, and in Home it would perform an implicit multiplication...

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
12-27-2017, 07:16 PM
Post: #4
RE: newbie question: how to take element from an array on command line
(12-27-2017 05:20 PM)iamhuzhe Wrote:  say `iquorem(63, 23)` returns [2, 17], how do I get 2, or 17 out of that array

Ans(1) should get you 2 and Ans(2) should get you 17 as one way (in CAS)

Cheers, Terje
Find all posts by this user
Quote this message in a reply
12-27-2017, 08:57 PM
Post: #5
RE: newbie question: how to take element from an array on command line
(12-27-2017 06:38 PM)salvomic Wrote:  
(12-27-2017 06:10 PM)Arno K Wrote:  Perhaps with 'iquorem(63,23)[1]' or [2]
Arno

Using [1] (or [2]) is ok in CAS, however, and in Home it would perform an implicit multiplication...

I totally forgot about that as I ususally always work in CAS. So here a solution is:
L1:=iquorem(63,23);
L1(1), recalls the first element of the result, that is 2
Arno
Find all posts by this user
Quote this message in a reply
12-27-2017, 09:05 PM
Post: #6
RE: newbie question: how to take element from an array on command line
(12-27-2017 08:57 PM)Arno K Wrote:  I totally forgot about that as I ususally always work in CAS. So here a solution is:
L1:=iquorem(63,23);
L1(1), recalls the first element of the result, that is 2
Arno

Right...
Maybe it is useful a more general way, that would be valid both in CAS and Home, to extract elements from matrices and vectors [].
i.e. in Home M1(2,3) is ok but [[1,2,3],[4,5,6],[7,8,9]] [2,3] tries to multiply, instead of extracting elements (in CAS that's ok).

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
12-30-2017, 08:20 PM
Post: #7
RE: newbie question: how to take element from an array on command line
A possible solution:

a:=iquorem(63,23)
a(1)
a(2)

   

Best Regards
Rudi
Find all posts by this user
Quote this message in a reply
Post Reply 




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